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
540 struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, in ceph_osdc_alloc_request() argument
550 req = mempool_alloc(osdc->req_mempool, gfp_flags); in ceph_osdc_alloc_request()
561 req->r_osdc = osdc; in ceph_osdc_alloc_request()
581 struct ceph_osd_client *osdc = req->r_osdc; in __ceph_osdc_alloc_messages() local
607 msg = ceph_msgpool_get(&osdc->msgpool_op, msg_size, in __ceph_osdc_alloc_messages()
624 msg = ceph_msgpool_get(&osdc->msgpool_op_reply, msg_size, in __ceph_osdc_alloc_messages()
1043 struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, in ceph_osdc_new_request() argument
1064 req = ceph_osdc_alloc_request(osdc, snapc, num_ops, use_mempool, in ceph_osdc_new_request()
1097 req->r_flags = flags | osdc->client->options->read_from_replica; in ceph_osdc_new_request()
1132 static void for_each_request(struct ceph_osd_client *osdc, in DEFINE_RB_FUNCS()
1138 for (n = rb_first(&osdc->osds); n; n = rb_next(n)) { in DEFINE_RB_FUNCS()
1151 for (p = rb_first(&osdc->homeless_osd.o_requests); p; ) { in DEFINE_RB_FUNCS()
1209 static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum) in create_osd() argument
1217 osd->o_osdc = osdc; in create_osd()
1220 ceph_con_init(&osd->o_con, osd, &osd_con_ops, &osdc->client->msgr); in create_osd()
1251 struct ceph_osd_client *osdc = osd->o_osdc; in DEFINE_RB_FUNCS() local
1256 spin_lock(&osdc->osd_lru_lock); in DEFINE_RB_FUNCS()
1257 list_add_tail(&osd->o_osd_lru, &osdc->osd_lru); in DEFINE_RB_FUNCS()
1258 spin_unlock(&osdc->osd_lru_lock); in DEFINE_RB_FUNCS()
1260 osd->lru_ttl = jiffies + osdc->client->options->osd_idle_ttl; in DEFINE_RB_FUNCS()
1272 struct ceph_osd_client *osdc = osd->o_osdc; in __remove_osd_from_lru() local
1276 spin_lock(&osdc->osd_lru_lock); in __remove_osd_from_lru()
1279 spin_unlock(&osdc->osd_lru_lock); in __remove_osd_from_lru()
1288 struct ceph_osd_client *osdc = osd->o_osdc; in close_osd() local
1291 verify_osdc_wrlocked(osdc); in close_osd()
1304 link_request(&osdc->homeless_osd, req); in close_osd()
1315 link_linger(&osdc->homeless_osd, lreq); in close_osd()
1320 erase_osd(&osdc->osds, osd); in close_osd()
1363 static struct ceph_osd *lookup_create_osd(struct ceph_osd_client *osdc, int o, in lookup_create_osd() argument
1369 verify_osdc_wrlocked(osdc); in lookup_create_osd()
1371 verify_osdc_locked(osdc); in lookup_create_osd()
1374 osd = lookup_osd(&osdc->osds, o); in lookup_create_osd()
1376 osd = &osdc->homeless_osd; in lookup_create_osd()
1381 osd = create_osd(osdc, o); in lookup_create_osd()
1382 insert_osd(&osdc->osds, osd); in lookup_create_osd()
1384 &osdc->osdmap->osd_addr[osd->o_osd]); in lookup_create_osd()
1387 dout("%s osdc %p osd%d -> osd %p\n", __func__, osdc, o, osd); in lookup_create_osd()
1435 static bool have_pool_full(struct ceph_osd_client *osdc) in have_pool_full() argument
1439 for (n = rb_first(&osdc->osdmap->pg_pools); n; n = rb_next(n)) { in have_pool_full()
1450 static bool pool_full(struct ceph_osd_client *osdc, s64 pool_id) in pool_full() argument
1454 pi = ceph_pg_pool_by_id(osdc->osdmap, pool_id); in pool_full()
1465 static bool target_should_be_paused(struct ceph_osd_client *osdc, in target_should_be_paused() argument
1469 bool pauserd = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD); in target_should_be_paused()
1470 bool pausewr = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR) || in target_should_be_paused()
1471 ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in target_should_be_paused()
1477 (osdc->osdmap->epoch < osdc->epoch_barrier); in target_should_be_paused()
1494 static int pick_closest_replica(struct ceph_osd_client *osdc, in pick_closest_replica() argument
1497 struct ceph_options *opt = osdc->client->options; in pick_closest_replica()
1502 locality = ceph_get_crush_locality(osdc->osdmap, in pick_closest_replica()
1525 static enum calc_target_result calc_target(struct ceph_osd_client *osdc, in calc_target() argument
1538 bool sort_bitwise = ceph_osdmap_flag(osdc, CEPH_OSDMAP_SORTBITWISE); in calc_target()
1539 bool recovery_deletes = ceph_osdmap_flag(osdc, in calc_target()
1543 t->epoch = osdc->osdmap->epoch; in calc_target()
1544 pi = ceph_pg_pool_by_id(osdc->osdmap, t->base_oloc.pool); in calc_target()
1551 if (osdc->osdmap->epoch == pi->last_force_request_resend) { in calc_target()
1569 pi = ceph_pg_pool_by_id(osdc->osdmap, t->target_oloc.pool); in calc_target()
1581 ceph_pg_to_up_acting_osds(osdc->osdmap, pi, &pgid, &up, &acting); in calc_target()
1600 if (t->paused && !target_should_be_paused(osdc, t, pi)) { in calc_target()
1612 ceph_pg_to_primary_shard(osdc->osdmap, pi, &pgid, &t->spgid); in calc_target()
1632 pos = pick_closest_replica(osdc, &acting); in calc_target()
2293 static void maybe_request_map(struct ceph_osd_client *osdc) in maybe_request_map() argument
2297 verify_osdc_locked(osdc); in maybe_request_map()
2298 WARN_ON(!osdc->osdmap->epoch); in maybe_request_map()
2300 if (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in maybe_request_map()
2301 ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD) || in maybe_request_map()
2302 ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR)) { in maybe_request_map()
2303 dout("%s osdc %p continuous\n", __func__, osdc); in maybe_request_map()
2306 dout("%s osdc %p onetime\n", __func__, osdc); in maybe_request_map()
2309 if (ceph_monc_want_map(&osdc->client->monc, CEPH_SUB_OSDMAP, in maybe_request_map()
2310 osdc->osdmap->epoch + 1, continuous)) in maybe_request_map()
2311 ceph_monc_renew_subs(&osdc->client->monc); in maybe_request_map()
2319 struct ceph_osd_client *osdc = req->r_osdc; in __submit_request() local
2330 ct_res = calc_target(osdc, &req->r_t, false); in __submit_request()
2334 osd = lookup_create_osd(osdc, req->r_t.osd, wrlocked); in __submit_request()
2340 if (osdc->abort_err) { in __submit_request()
2341 dout("req %p abort_err %d\n", req, osdc->abort_err); in __submit_request()
2342 err = osdc->abort_err; in __submit_request()
2343 } else if (osdc->osdmap->epoch < osdc->epoch_barrier) { in __submit_request()
2344 dout("req %p epoch %u barrier %u\n", req, osdc->osdmap->epoch, in __submit_request()
2345 osdc->epoch_barrier); in __submit_request()
2347 maybe_request_map(osdc); in __submit_request()
2349 ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR)) { in __submit_request()
2352 maybe_request_map(osdc); in __submit_request()
2354 ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD)) { in __submit_request()
2357 maybe_request_map(osdc); in __submit_request()
2361 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in __submit_request()
2362 pool_full(osdc, req->r_t.base_oloc.pool))) { in __submit_request()
2364 if (ceph_test_opt(osdc->client, ABORT_ON_FULL)) { in __submit_request()
2367 if (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL)) in __submit_request()
2373 maybe_request_map(osdc); in __submit_request()
2378 maybe_request_map(osdc); in __submit_request()
2387 req->r_tid = atomic64_inc_return(&osdc->last_tid); in __submit_request()
2399 downgrade_write(&osdc->lock); in __submit_request()
2403 up_read(&osdc->lock); in __submit_request()
2404 down_write(&osdc->lock); in __submit_request()
2431 struct ceph_osd_client *osdc = req->r_osdc; in finish_request() local
2433 WARN_ON(lookup_request_mc(&osdc->map_checks, req->r_tid)); in finish_request()
2440 atomic_dec(&osdc->num_requests); in finish_request()
2487 struct ceph_osd_client *osdc = req->r_osdc; in cancel_map_check() local
2490 verify_osdc_wrlocked(osdc); in cancel_map_check()
2492 lookup_req = lookup_request_mc(&osdc->map_checks, req->r_tid); in cancel_map_check()
2497 erase_request_mc(&osdc->map_checks, req); in cancel_map_check()
2531 void ceph_osdc_abort_requests(struct ceph_osd_client *osdc, int err) in ceph_osdc_abort_requests() argument
2533 dout("%s osdc %p err %d\n", __func__, osdc, err); in ceph_osdc_abort_requests()
2534 down_write(&osdc->lock); in ceph_osdc_abort_requests()
2535 for_each_request(osdc, abort_fn, &err); in ceph_osdc_abort_requests()
2536 osdc->abort_err = err; in ceph_osdc_abort_requests()
2537 up_write(&osdc->lock); in ceph_osdc_abort_requests()
2541 void ceph_osdc_clear_abort_err(struct ceph_osd_client *osdc) in ceph_osdc_clear_abort_err() argument
2543 down_write(&osdc->lock); in ceph_osdc_clear_abort_err()
2544 osdc->abort_err = 0; in ceph_osdc_clear_abort_err()
2545 up_write(&osdc->lock); in ceph_osdc_clear_abort_err()
2549 static void update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb) in update_epoch_barrier() argument
2551 if (likely(eb > osdc->epoch_barrier)) { in update_epoch_barrier()
2553 osdc->epoch_barrier, eb); in update_epoch_barrier()
2554 osdc->epoch_barrier = eb; in update_epoch_barrier()
2556 if (eb > osdc->osdmap->epoch) in update_epoch_barrier()
2557 maybe_request_map(osdc); in update_epoch_barrier()
2561 void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb) in ceph_osdc_update_epoch_barrier() argument
2563 down_read(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2564 if (unlikely(eb > osdc->epoch_barrier)) { in ceph_osdc_update_epoch_barrier()
2565 up_read(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2566 down_write(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2567 update_epoch_barrier(osdc, eb); in ceph_osdc_update_epoch_barrier()
2568 up_write(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2570 up_read(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2583 struct ceph_osd_client *osdc = req->r_osdc; in abort_on_full_fn() local
2587 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in abort_on_full_fn()
2588 pool_full(osdc, req->r_t.base_oloc.pool))) { in abort_on_full_fn()
2590 update_epoch_barrier(osdc, osdc->osdmap->epoch); in abort_on_full_fn()
2605 static void ceph_osdc_abort_on_full(struct ceph_osd_client *osdc) in ceph_osdc_abort_on_full() argument
2609 if (ceph_test_opt(osdc->client, ABORT_ON_FULL) && in ceph_osdc_abort_on_full()
2610 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || have_pool_full(osdc))) in ceph_osdc_abort_on_full()
2611 for_each_request(osdc, abort_on_full_fn, &victims); in ceph_osdc_abort_on_full()
2616 struct ceph_osd_client *osdc = req->r_osdc; in check_pool_dne() local
2617 struct ceph_osdmap *map = osdc->osdmap; in check_pool_dne()
2619 verify_osdc_wrlocked(osdc); in check_pool_dne()
2650 struct ceph_osd_client *osdc = &greq->monc->client->osdc; in map_check_cb() local
2656 down_write(&osdc->lock); in map_check_cb()
2657 req = lookup_request_mc(&osdc->map_checks, tid); in map_check_cb()
2667 erase_request_mc(&osdc->map_checks, req); in map_check_cb()
2672 up_write(&osdc->lock); in map_check_cb()
2677 struct ceph_osd_client *osdc = req->r_osdc; in send_map_check() local
2681 verify_osdc_wrlocked(osdc); in send_map_check()
2683 lookup_req = lookup_request_mc(&osdc->map_checks, req->r_tid); in send_map_check()
2690 insert_request_mc(&osdc->map_checks, req); in send_map_check()
2691 ret = ceph_monc_get_version_async(&osdc->client->monc, "osdmap", in send_map_check()
2738 linger_alloc(struct ceph_osd_client *osdc) in linger_alloc() argument
2756 lreq->osdc = osdc; in linger_alloc()
2810 verify_osdc_locked(lreq->osdc); in __linger_registered()
2817 struct ceph_osd_client *osdc = lreq->osdc; in linger_registered() local
2820 down_read(&osdc->lock); in linger_registered()
2822 up_read(&osdc->lock); in linger_registered()
2829 struct ceph_osd_client *osdc = lreq->osdc; in linger_register() local
2831 verify_osdc_wrlocked(osdc); in linger_register()
2835 lreq->linger_id = ++osdc->last_linger_id; in linger_register()
2836 insert_linger_osdc(&osdc->linger_requests, lreq); in linger_register()
2841 struct ceph_osd_client *osdc = lreq->osdc; in linger_unregister() local
2843 verify_osdc_wrlocked(osdc); in linger_unregister()
2845 erase_linger_osdc(&osdc->linger_requests, lreq); in linger_unregister()
2910 struct ceph_osd_client *osdc = lreq->osdc; in lwork_queue() local
2917 queue_work(osdc->notify_wq, &lwork->work); in lwork_queue()
3062 struct ceph_osd_client *osdc = lreq->osdc; in send_linger() local
3066 verify_osdc_wrlocked(osdc); in send_linger()
3076 req = ceph_osdc_alloc_request(osdc, NULL, 1, true, GFP_NOIO); in send_linger()
3150 struct ceph_osd_client *osdc = lreq->osdc; in send_linger_ping() local
3154 if (ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD)) { in send_linger_ping()
3170 req = ceph_osdc_alloc_request(osdc, NULL, 1, true, GFP_NOIO); in send_linger_ping()
3187 req->r_tid = atomic64_inc_return(&osdc->last_tid); in send_linger_ping()
3194 struct ceph_osd_client *osdc = lreq->osdc; in linger_submit() local
3197 down_write(&osdc->lock); in linger_submit()
3200 calc_target(osdc, &lreq->t, false); in linger_submit()
3201 osd = lookup_create_osd(osdc, lreq->t.osd, true); in linger_submit()
3205 up_write(&osdc->lock); in linger_submit()
3210 struct ceph_osd_client *osdc = lreq->osdc; in cancel_linger_map_check() local
3213 verify_osdc_wrlocked(osdc); in cancel_linger_map_check()
3215 lookup_lreq = lookup_linger_mc(&osdc->linger_map_checks, in cancel_linger_map_check()
3221 erase_linger_mc(&osdc->linger_map_checks, lreq); in cancel_linger_map_check()
3241 struct ceph_osd_client *osdc = lreq->osdc; in linger_cancel() local
3243 down_write(&osdc->lock); in linger_cancel()
3246 up_write(&osdc->lock); in linger_cancel()
3253 struct ceph_osd_client *osdc = lreq->osdc; in check_linger_pool_dne() local
3254 struct ceph_osdmap *map = osdc->osdmap; in check_linger_pool_dne()
3256 verify_osdc_wrlocked(osdc); in check_linger_pool_dne()
3284 struct ceph_osd_client *osdc = &greq->monc->client->osdc; in linger_map_check_cb() local
3290 down_write(&osdc->lock); in linger_map_check_cb()
3291 lreq = lookup_linger_mc(&osdc->linger_map_checks, linger_id); in linger_map_check_cb()
3302 erase_linger_mc(&osdc->linger_map_checks, lreq); in linger_map_check_cb()
3307 up_write(&osdc->lock); in linger_map_check_cb()
3312 struct ceph_osd_client *osdc = lreq->osdc; in send_linger_map_check() local
3316 verify_osdc_wrlocked(osdc); in send_linger_map_check()
3318 lookup_lreq = lookup_linger_mc(&osdc->linger_map_checks, in send_linger_map_check()
3326 insert_linger_mc(&osdc->linger_map_checks, lreq); in send_linger_map_check()
3327 ret = ceph_monc_get_version_async(&osdc->client->monc, "osdmap", in send_linger_map_check()
3358 struct ceph_osd_client *osdc = in handle_timeout() local
3360 struct ceph_options *opts = osdc->client->options; in handle_timeout()
3366 dout("%s osdc %p\n", __func__, osdc); in handle_timeout()
3367 down_write(&osdc->lock); in handle_timeout()
3374 for (n = rb_first(&osdc->osds); n; n = rb_next(n)) { in handle_timeout()
3415 for (p = rb_first(&osdc->homeless_osd.o_requests); p; ) { in handle_timeout()
3423 req->r_tid, osdc->homeless_osd.o_osd); in handle_timeout()
3429 if (atomic_read(&osdc->num_homeless) || !list_empty(&slow_osds)) in handle_timeout()
3430 maybe_request_map(osdc); in handle_timeout()
3440 up_write(&osdc->lock); in handle_timeout()
3441 schedule_delayed_work(&osdc->timeout_work, in handle_timeout()
3442 osdc->client->options->osd_keepalive_timeout); in handle_timeout()
3447 struct ceph_osd_client *osdc = in handle_osds_timeout() local
3450 unsigned long delay = osdc->client->options->osd_idle_ttl / 4; in handle_osds_timeout()
3453 dout("%s osdc %p\n", __func__, osdc); in handle_osds_timeout()
3454 down_write(&osdc->lock); in handle_osds_timeout()
3455 list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) { in handle_osds_timeout()
3464 up_write(&osdc->lock); in handle_osds_timeout()
3465 schedule_delayed_work(&osdc->osds_timeout_work, in handle_osds_timeout()
3678 struct ceph_osd_client *osdc = osd->o_osdc; in handle_reply() local
3688 down_read(&osdc->lock); in handle_reply()
3794 up_read(&osdc->lock); in handle_reply()
3804 up_read(&osdc->lock); in handle_reply()
3807 static void set_pool_was_full(struct ceph_osd_client *osdc) in set_pool_was_full() argument
3811 for (n = rb_first(&osdc->osdmap->pg_pools); n; n = rb_next(n)) { in set_pool_was_full()
3819 static bool pool_cleared_full(struct ceph_osd_client *osdc, s64 pool_id) in pool_cleared_full() argument
3823 pi = ceph_pg_pool_by_id(osdc->osdmap, pool_id); in pool_cleared_full()
3833 struct ceph_osd_client *osdc = lreq->osdc; in recalc_linger_target() local
3836 ct_res = calc_target(osdc, &lreq->t, true); in recalc_linger_target()
3840 osd = lookup_create_osd(osdc, lreq->t.osd, true); in recalc_linger_target()
3860 struct ceph_osd_client *osdc = osd->o_osdc; in scan_requests() local
3878 pool_cleared_full(osdc, lreq->t.base_oloc.pool)); in scan_requests()
3908 ct_res = calc_target(osdc, &req->r_t, false); in scan_requests()
3913 pool_cleared_full(osdc, req->r_t.base_oloc.pool)); in scan_requests()
3932 static int handle_one_map(struct ceph_osd_client *osdc, in handle_one_map() argument
3942 was_full = ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL); in handle_one_map()
3943 set_pool_was_full(osdc); in handle_one_map()
3947 ceph_msgr2(osdc->client), in handle_one_map()
3948 osdc->osdmap); in handle_one_map()
3950 newmap = ceph_osdmap_decode(&p, end, ceph_msgr2(osdc->client)); in handle_one_map()
3954 if (newmap != osdc->osdmap) { in handle_one_map()
3965 old_pi = ceph_pg_pool_by_id(osdc->osdmap, pi->id); in handle_one_map()
3972 if (osdc->osdmap->epoch && in handle_one_map()
3973 osdc->osdmap->epoch + 1 < newmap->epoch) { in handle_one_map()
3978 ceph_osdmap_destroy(osdc->osdmap); in handle_one_map()
3979 osdc->osdmap = newmap; in handle_one_map()
3982 was_full &= !ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL); in handle_one_map()
3983 scan_requests(&osdc->homeless_osd, skipped_map, was_full, true, in handle_one_map()
3986 for (n = rb_first(&osdc->osds); n; ) { in handle_one_map()
3993 if (!ceph_osd_is_up(osdc->osdmap, osd->o_osd) || in handle_one_map()
3995 ceph_osd_addr(osdc->osdmap, osd->o_osd), in handle_one_map()
4003 static void kick_requests(struct ceph_osd_client *osdc, in kick_requests() argument
4018 if (req->r_t.epoch < osdc->osdmap->epoch) { in kick_requests()
4019 ct_res = calc_target(osdc, &req->r_t, false); in kick_requests()
4035 osd = lookup_create_osd(osdc, req->r_t.osd, true); in kick_requests()
4060 void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) in ceph_osdc_handle_map() argument
4074 dout("%s have %u\n", __func__, osdc->osdmap->epoch); in ceph_osdc_handle_map()
4075 down_write(&osdc->lock); in ceph_osdc_handle_map()
4080 if (ceph_check_fsid(osdc->client, &fsid) < 0) in ceph_osdc_handle_map()
4083 was_pauserd = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD); in ceph_osdc_handle_map()
4084 was_pausewr = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR) || in ceph_osdc_handle_map()
4085 ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in ceph_osdc_handle_map()
4086 have_pool_full(osdc); in ceph_osdc_handle_map()
4096 if (osdc->osdmap->epoch && in ceph_osdc_handle_map()
4097 osdc->osdmap->epoch + 1 == epoch) { in ceph_osdc_handle_map()
4100 err = handle_one_map(osdc, p, p + maplen, true, in ceph_osdc_handle_map()
4126 } else if (osdc->osdmap->epoch >= epoch) { in ceph_osdc_handle_map()
4129 osdc->osdmap->epoch); in ceph_osdc_handle_map()
4132 err = handle_one_map(osdc, p, p + maplen, false, in ceph_osdc_handle_map()
4147 pauserd = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD); in ceph_osdc_handle_map()
4148 pausewr = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR) || in ceph_osdc_handle_map()
4149 ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in ceph_osdc_handle_map()
4150 have_pool_full(osdc); in ceph_osdc_handle_map()
4152 osdc->osdmap->epoch < osdc->epoch_barrier) in ceph_osdc_handle_map()
4153 maybe_request_map(osdc); in ceph_osdc_handle_map()
4155 kick_requests(osdc, &need_resend, &need_resend_linger); in ceph_osdc_handle_map()
4157 ceph_osdc_abort_on_full(osdc); in ceph_osdc_handle_map()
4158 ceph_monc_got_map(&osdc->client->monc, CEPH_SUB_OSDMAP, in ceph_osdc_handle_map()
4159 osdc->osdmap->epoch); in ceph_osdc_handle_map()
4160 up_write(&osdc->lock); in ceph_osdc_handle_map()
4161 wake_up_all(&osdc->client->auth_wq); in ceph_osdc_handle_map()
4167 up_write(&osdc->lock); in ceph_osdc_handle_map()
4206 struct ceph_osd_client *osdc = osd->o_osdc; in osd_fault() local
4210 down_write(&osdc->lock); in osd_fault()
4218 maybe_request_map(osdc); in osd_fault()
4221 up_write(&osdc->lock); in osd_fault()
4440 struct ceph_osd_client *osdc = osd->o_osdc; in handle_backoff() local
4444 down_read(&osdc->lock); in handle_backoff()
4447 up_read(&osdc->lock); in handle_backoff()
4476 up_read(&osdc->lock); in handle_backoff()
4482 static void handle_watch_notify(struct ceph_osd_client *osdc, in handle_watch_notify() argument
4515 down_read(&osdc->lock); in handle_watch_notify()
4516 lreq = lookup_linger_osdc(&osdc->linger_requests, cookie); in handle_watch_notify()
4571 up_read(&osdc->lock); in handle_watch_notify()
4581 void ceph_osdc_start_request(struct ceph_osd_client *osdc, in ceph_osdc_start_request() argument
4584 down_read(&osdc->lock); in ceph_osdc_start_request()
4586 up_read(&osdc->lock); in ceph_osdc_start_request()
4601 struct ceph_osd_client *osdc = req->r_osdc; in ceph_osdc_cancel_request() local
4603 down_write(&osdc->lock); in ceph_osdc_cancel_request()
4606 up_write(&osdc->lock); in ceph_osdc_cancel_request()
4634 int ceph_osdc_wait_request(struct ceph_osd_client *osdc, in ceph_osdc_wait_request() argument
4644 void ceph_osdc_sync(struct ceph_osd_client *osdc) in ceph_osdc_sync() argument
4647 u64 last_tid = atomic64_read(&osdc->last_tid); in ceph_osdc_sync()
4650 down_read(&osdc->lock); in ceph_osdc_sync()
4651 for (n = rb_first(&osdc->osds); n; n = rb_next(n)) { in ceph_osdc_sync()
4667 up_read(&osdc->lock); in ceph_osdc_sync()
4678 up_read(&osdc->lock); in ceph_osdc_sync()
4687 ceph_osdc_watch(struct ceph_osd_client *osdc, in ceph_osdc_watch() argument
4697 lreq = linger_alloc(osdc); in ceph_osdc_watch()
4734 int ceph_osdc_unwatch(struct ceph_osd_client *osdc, in ceph_osdc_unwatch() argument
4737 struct ceph_options *opts = osdc->client->options; in ceph_osdc_unwatch()
4741 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_unwatch()
4756 ceph_osdc_start_request(osdc, req); in ceph_osdc_unwatch()
4799 int ceph_osdc_notify_ack(struct ceph_osd_client *osdc, in ceph_osdc_notify_ack() argument
4810 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_notify_ack()
4827 ceph_osdc_start_request(osdc, req); in ceph_osdc_notify_ack()
4828 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_notify_ack()
4844 int ceph_osdc_notify(struct ceph_osd_client *osdc, in ceph_osdc_notify() argument
4862 lreq = linger_alloc(osdc); in ceph_osdc_notify()
4915 int ceph_osdc_watch_check(struct ceph_osd_client *osdc, in ceph_osdc_watch_check() argument
4921 down_read(&osdc->lock); in ceph_osdc_watch_check()
4940 up_read(&osdc->lock); in ceph_osdc_watch_check()
5010 int ceph_osdc_list_watchers(struct ceph_osd_client *osdc, in ceph_osdc_list_watchers() argument
5020 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_list_watchers()
5043 ceph_osdc_start_request(osdc, req); in ceph_osdc_list_watchers()
5044 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_list_watchers()
5062 void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc) in ceph_osdc_flush_notifies() argument
5064 dout("%s osdc %p\n", __func__, osdc); in ceph_osdc_flush_notifies()
5065 flush_workqueue(osdc->notify_wq); in ceph_osdc_flush_notifies()
5069 void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc) in ceph_osdc_maybe_request_map() argument
5071 down_read(&osdc->lock); in ceph_osdc_maybe_request_map()
5072 maybe_request_map(osdc); in ceph_osdc_maybe_request_map()
5073 up_read(&osdc->lock); in ceph_osdc_maybe_request_map()
5083 int ceph_osdc_call(struct ceph_osd_client *osdc, in ceph_osdc_call() argument
5097 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_call()
5120 ceph_osdc_start_request(osdc, req); in ceph_osdc_call()
5121 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_call()
5137 void ceph_osdc_reopen_osds(struct ceph_osd_client *osdc) in ceph_osdc_reopen_osds() argument
5141 down_write(&osdc->lock); in ceph_osdc_reopen_osds()
5142 for (n = rb_first(&osdc->osds); n; ) { in ceph_osdc_reopen_osds()
5149 up_write(&osdc->lock); in ceph_osdc_reopen_osds()
5155 int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client) in ceph_osdc_init() argument
5160 osdc->client = client; in ceph_osdc_init()
5161 init_rwsem(&osdc->lock); in ceph_osdc_init()
5162 osdc->osds = RB_ROOT; in ceph_osdc_init()
5163 INIT_LIST_HEAD(&osdc->osd_lru); in ceph_osdc_init()
5164 spin_lock_init(&osdc->osd_lru_lock); in ceph_osdc_init()
5165 osd_init(&osdc->homeless_osd); in ceph_osdc_init()
5166 osdc->homeless_osd.o_osdc = osdc; in ceph_osdc_init()
5167 osdc->homeless_osd.o_osd = CEPH_HOMELESS_OSD; in ceph_osdc_init()
5168 osdc->last_linger_id = CEPH_LINGER_ID_START; in ceph_osdc_init()
5169 osdc->linger_requests = RB_ROOT; in ceph_osdc_init()
5170 osdc->map_checks = RB_ROOT; in ceph_osdc_init()
5171 osdc->linger_map_checks = RB_ROOT; in ceph_osdc_init()
5172 INIT_DELAYED_WORK(&osdc->timeout_work, handle_timeout); in ceph_osdc_init()
5173 INIT_DELAYED_WORK(&osdc->osds_timeout_work, handle_osds_timeout); in ceph_osdc_init()
5176 osdc->osdmap = ceph_osdmap_alloc(); in ceph_osdc_init()
5177 if (!osdc->osdmap) in ceph_osdc_init()
5180 osdc->req_mempool = mempool_create_slab_pool(10, in ceph_osdc_init()
5182 if (!osdc->req_mempool) in ceph_osdc_init()
5185 err = ceph_msgpool_init(&osdc->msgpool_op, CEPH_MSG_OSD_OP, in ceph_osdc_init()
5189 err = ceph_msgpool_init(&osdc->msgpool_op_reply, CEPH_MSG_OSD_OPREPLY, in ceph_osdc_init()
5196 osdc->notify_wq = create_singlethread_workqueue("ceph-watch-notify"); in ceph_osdc_init()
5197 if (!osdc->notify_wq) in ceph_osdc_init()
5200 osdc->completion_wq = create_singlethread_workqueue("ceph-completion"); in ceph_osdc_init()
5201 if (!osdc->completion_wq) in ceph_osdc_init()
5204 schedule_delayed_work(&osdc->timeout_work, in ceph_osdc_init()
5205 osdc->client->options->osd_keepalive_timeout); in ceph_osdc_init()
5206 schedule_delayed_work(&osdc->osds_timeout_work, in ceph_osdc_init()
5207 round_jiffies_relative(osdc->client->options->osd_idle_ttl)); in ceph_osdc_init()
5212 destroy_workqueue(osdc->notify_wq); in ceph_osdc_init()
5214 ceph_msgpool_destroy(&osdc->msgpool_op_reply); in ceph_osdc_init()
5216 ceph_msgpool_destroy(&osdc->msgpool_op); in ceph_osdc_init()
5218 mempool_destroy(osdc->req_mempool); in ceph_osdc_init()
5220 ceph_osdmap_destroy(osdc->osdmap); in ceph_osdc_init()
5225 void ceph_osdc_stop(struct ceph_osd_client *osdc) in ceph_osdc_stop() argument
5227 destroy_workqueue(osdc->completion_wq); in ceph_osdc_stop()
5228 destroy_workqueue(osdc->notify_wq); in ceph_osdc_stop()
5229 cancel_delayed_work_sync(&osdc->timeout_work); in ceph_osdc_stop()
5230 cancel_delayed_work_sync(&osdc->osds_timeout_work); in ceph_osdc_stop()
5232 down_write(&osdc->lock); in ceph_osdc_stop()
5233 while (!RB_EMPTY_ROOT(&osdc->osds)) { in ceph_osdc_stop()
5234 struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds), in ceph_osdc_stop()
5238 up_write(&osdc->lock); in ceph_osdc_stop()
5239 WARN_ON(refcount_read(&osdc->homeless_osd.o_ref) != 1); in ceph_osdc_stop()
5240 osd_cleanup(&osdc->homeless_osd); in ceph_osdc_stop()
5242 WARN_ON(!list_empty(&osdc->osd_lru)); in ceph_osdc_stop()
5243 WARN_ON(!RB_EMPTY_ROOT(&osdc->linger_requests)); in ceph_osdc_stop()
5244 WARN_ON(!RB_EMPTY_ROOT(&osdc->map_checks)); in ceph_osdc_stop()
5245 WARN_ON(!RB_EMPTY_ROOT(&osdc->linger_map_checks)); in ceph_osdc_stop()
5246 WARN_ON(atomic_read(&osdc->num_requests)); in ceph_osdc_stop()
5247 WARN_ON(atomic_read(&osdc->num_homeless)); in ceph_osdc_stop()
5249 ceph_osdmap_destroy(osdc->osdmap); in ceph_osdc_stop()
5250 mempool_destroy(osdc->req_mempool); in ceph_osdc_stop()
5251 ceph_msgpool_destroy(&osdc->msgpool_op); in ceph_osdc_stop()
5252 ceph_msgpool_destroy(&osdc->msgpool_op_reply); in ceph_osdc_stop()
5318 struct ceph_osd_client *osdc = osd->o_osdc; in osd_dispatch() local
5323 ceph_osdc_handle_map(osdc, msg); in osd_dispatch()
5332 handle_watch_notify(osdc, msg); in osd_dispatch()
5353 struct ceph_osd_client *osdc = osd->o_osdc; in get_reply() local
5360 down_read(&osdc->lock); in get_reply()
5406 up_read(&osdc->lock); in get_reply()
5489 struct ceph_osd_client *osdc = o->o_osdc; in osd_get_authorizer() local
5490 struct ceph_auth_client *ac = osdc->client->monc.auth; in osd_get_authorizer()
5506 struct ceph_osd_client *osdc = o->o_osdc; in osd_add_authorizer_challenge() local
5507 struct ceph_auth_client *ac = osdc->client->monc.auth; in osd_add_authorizer_challenge()
5516 struct ceph_osd_client *osdc = o->o_osdc; in osd_verify_authorizer_reply() local
5517 struct ceph_auth_client *ac = osdc->client->monc.auth; in osd_verify_authorizer_reply()
5528 struct ceph_osd_client *osdc = o->o_osdc; in osd_invalidate_authorizer() local
5529 struct ceph_auth_client *ac = osdc->client->monc.auth; in osd_invalidate_authorizer()
5532 return ceph_monc_validate_auth(&osdc->client->monc); in osd_invalidate_authorizer()