24 #undef M0_TRACE_SUBSYSTEM 25 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_RM 126 #define INCOMING_CREDIT(in) in->rin_want.cr_datum 137 cr_linkage, cr_magix,
142 rem_res_linkage, rem_magix,
147 ro_owner_linkage, ro_magix,
160 rp_credit_linkage, rp_magix,
165 rp_incoming_linkage, rp_magix,
196 .
bt_name =
"outgoing request ",
204 .
bt_name =
"proxy for remote owner ",
263 res_tlist_init(&
rt->rt_resources);
264 rt->rt_nr_resources = 0;
269 rt->rt_stop_worker =
false;
306 rt->rt_stop_worker =
true;
318 res_tlist_fini(&
rt->rt_resources);
328 const uint64_t rtype_id)
334 return dom->rd_types[rtype_id];
340 M0_ENTRY(
"res-type: %p resource : %p", rtype,
res);
348 m0_remotes_tlist_init(&
res->r_remotes);
350 m0_owners_tlist_init(&
res->r_local);
351 m0_rm_resource_bob_init(
res);
369 M0_PRE(m0_remotes_tlist_is_empty(&
res->r_remotes));
370 M0_PRE(m0_owners_tlist_is_empty(&
res->r_local));
373 res_tlink_del_fini(
res);
378 m0_remotes_tlist_fini(&
res->r_remotes);
379 m0_owners_tlist_fini(&
res->r_local);
380 m0_rm_resource_bob_fini(
res);
390 res->r_ops->rop_resource_free(
res);
411 buf->b_nob =
sizeof res->r_type->rt_id +
412 res->r_type->rt_ops->rto_len(
res);
428 sizeof res->r_type->rt_id);
429 return M0_RC(
res->r_type->rt_ops->rto_encode(&cursor,
res));
468 .sd_name =
"Initialising",
476 .sd_name =
"Quiesce",
480 .sd_name =
"Finalising",
486 .sd_name =
"Creditor_is_dead",
491 .sd_name =
"Insolvent" 521 M0_LOG(
M0_INFO,
"Owner: %p, state change:[%s -> %s] err %d\n",
620 M0_ENTRY(
"owner: %p resource: %p creditor: %p",
640 m0_owners_tlink_init_at_tail(owner, &
res->r_local);
674 event =
M0_AMB(event, q_link, rhe_link);
675 tracker =
event->rhe_tracker;
705 if (
rt->rt_stop_worker) {
747 if (nominal_capital !=
NULL && credit_transfer !=
NULL) {
835 M0_ASSERT(m0_rm_credit_bob_check(credit));
854 M0_ASSERT(m0_rm_credit_bob_check(credit));
858 m0_rm_ur_tlist_del(credit);
876 M0_ASSERT(m0_rm_credit_bob_check(credit));
878 m0_rm_ur_tlist_del(credit);
884 M0_ASSERT(m0_rm_credit_bob_check(credit));
886 m0_rm_ur_tlist_del(credit);
953 m0_owners_tlink_del_fini(owner);
967 M0_ENTRY(
"credit: %p with owner: %p", credit, owner);
974 m0_rm_ur_tlink_init(credit);
975 pr_tlist_init(&credit->
cr_pins);
976 m0_rm_credit_bob_init(credit);
990 m0_rm_ur_tlink_fini(credit);
991 pr_tlist_fini(&credit->
cr_pins);
992 m0_rm_credit_bob_fini(credit);
1001 .sd_name =
"Initialised",
1009 .sd_name =
"Success",
1014 .sd_name =
"Failure",
1022 .sd_name =
"Released",
1054 M0_LOG(
M0_INFO,
"Incoming req: %p, state change:[%s -> %s]\n",
1066 M0_ENTRY(
"incoming: %p for owner: %p", in, owner);
1076 m0_rm_incoming_bob_init(in);
1093 m0_rm_incoming_bob_fini(in);
1159 out->rog_type = req_type;
1160 out->rog_sent =
false;
1161 m0_rm_outgoing_bob_init(
out);
1171 m0_rm_outgoing_bob_fini(
out);
1195 if (new_loan !=
NULL) {
1223 (
long long unsigned) credit->
cr_datum);
1227 if (
rc != 0 && new_loan !=
NULL) {
1231 *remnant_loan = new_loan;
1246 m0_rm_loan_bob_init(loan);
1268 m0_rm_loan_bob_fini(loan);
1279 M0_ENTRY(
"owner: %p link: %p", owner, link);
1285 M0_ASSERT(m0_rm_credit_bob_check(credit));
1309 rem_rev_sess_clink, &
rem_bob);
1314 M0_LEAVE(
"remote rev_session status is not good: rc=%d",
rc);
1423 m0_remotes_tlink_init(rem);
1425 m0_rm_remote_bob_init(rem);
1451 if (conf_exp_chan ==
NULL) {
1460 m0_remotes_tlink_fini(rem);
1462 m0_rm_remote_bob_fini(rem);
1491 struct m0_tl retain_list;
1492 struct m0_tl remove_list;
1495 M0_ENTRY(
"owner: %p credit: %llu", owner,
1500 m0_rm_ur_tlist_init(&retain_list);
1501 m0_rm_ur_tlist_init(&remove_list);
1510 m0_rm_ur_tlist_move(&retain_list, credit);
1512 m0_rm_ur_tlist_move(&remove_list, credit);
1525 m0_rm_ur_tlist_add(&remove_list,
1528 m0_rm_ur_tlist_add(&retain_list,
1545 m0_tl_for (m0_rm_ur,
rc ? &remove_list : &retain_list, credit) {
1549 m0_rm_ur_tlist_fini(&retain_list);
1550 m0_rm_ur_tlist_fini(&remove_list);
1572 M0_ENTRY(
"owner: %p credit: %llu", o,
1594 pi_tlist_is_empty(&in->
rin_pins) ? 0 :
1598 if (
rc != 0 && loan !=
NULL) {
1601 }
else if (
rc == 0) {
1627 M0_ENTRY(
"owner: %p credit: %llu", owner,
1663 m0_rm_ur_tlist_del(credit);
1667 remove_loan = remnant_loan;
1669 add_loan = remnant_loan;
1671 remove_loan = remnant_loan;
1673 if (add_loan !=
NULL)
1676 if (remove_loan !=
NULL) {
1762 M0_ENTRY(
"owner: %p credit: %llu", owner,
1801 M0_ENTRY(
"owner: %p credit: %llu", owner,
1828 struct m0_tl transfers;
1831 M0_ENTRY(
"owner: %p credit: %llu", owner,
1841 m0_rm_ur_tlist_init(&transfers);
1865 m0_rm_ur_tlist_move(&transfers, credit);
1871 if (held_credit ==
NULL) {
1890 m0_rm_ur_tlist_add(&transfers, held_credit);
1907 m0_tl_for (m0_rm_ur, &transfers, credit) {
1908 m0_rm_ur_tlist_move(&owner->
ro_owned[ltype], credit);
1911 m0_rm_ur_tlist_fini(&transfers);
1951 M0_ASSERT(m0_rm_credit_bob_check(credit));
1965 out->rog_rc == -EAGAIN ? 0 :
out->rog_rc;
1979 m0_rm_ur_tlist_del(credit);
1991 m0_rm_ur_tlist_move(
2049 M0_PRE(m0_rm_incoming_bob_check(in));
2189 if (
rc == 0 && notify)
2254 *cr_used = (
rc == 0);
2353 bool use_credit =
false;
2358 M0_ENTRY(
"incoming: %p credit: %llu", in,
2359 (
long long unsigned) rest->
cr_datum);
2384 if (
rc == 0 && use_credit) {
2386 if (
rc == 0 &&
wait == 0)
2411 if (group_matches) {
2490 M0_ENTRY(
"incoming: %p error: [%d]", in,
rc);
2508 m0_rm_ur_tlist_remove(&in->
rin_want);
2561 if (
out->rog_type == otype &&
2564 out->rog_want.rl_other, other);
2576 out->rog_want.rl_other == other));
2582 out->rog_want.rl_other == other));
2588 if (
out->rog_want.rl_other == other)
2619 M0_ENTRY(
"incoming: %p credit: %llu", in,
2620 (
long long unsigned)credit->
cr_datum);
2634 loan, &rest, other);
2649 M0_ENTRY(
"incoming: %p credit: %llu", in,
2650 (
long long unsigned) credit->
cr_datum);
2664 NULL, credit, other) ?:
2697 struct m0_tl retain_list;
2698 struct m0_tl remove_list;
2703 M0_ENTRY(
"loan=%p credit: %llu", paid_loan,
2706 m0_rm_ur_tlist_init(&retain_list);
2707 m0_rm_ur_tlist_init(&remove_list);
2723 m0_rm_ur_tlist_add(&remove_list, &remnant_loan->
rl_credit);
2725 m0_rm_ur_tlist_add(&retain_list, &remnant_loan->
rl_credit);
2727 m0_rm_ur_tlist_move(&remove_list, cr);
2740 m0_tl_for (m0_rm_ur,
rc ? &remove_list : &retain_list, cr) {
2741 m0_rm_ur_tlist_move(
list, cr);
2744 m0_rm_ur_tlist_fini(&retain_list);
2745 m0_rm_ur_tlist_fini(&remove_list);
2758 M0_ENTRY(
"granted %p to_cache %p", granted, to_cache);
2796 M0_ENTRY(
"loan check against credit: %llu",
2797 (
long long unsigned) rest->
cr_datum);
2878 const struct m0_tl *rlist = &
rt->rt_resources;
2883 rt->rt_nr_resources == res_tlist_length(rlist) &&
2885 dom->rd_types[
rt->rt_id] ==
rt;
3005 if (!m0_rm_ur_tlist_invariant_ext(&owner->
ro_borrowed,
3009 if (!m0_rm_ur_tlist_invariant_ext(&owner->
ro_sublet,
3013 if (!m0_rm_ur_tlist_invariant_ext(&owner->
ro_outgoing[0],
3019 is->is_owned_idx =
i;
3020 if (!m0_rm_ur_tlist_invariant_ext(&owner->
ro_owned[
i],
3035 m0_rm_ur_tlist_invariant
3039 credit->cr_ops->cro_join(&is->is_credit,
3042 credit->cr_ops->cro_join(&is->is_credit,
3046 credit->cr_ops->cro_join(&is->is_debit, credit))));
3130 M0_ASSERT(m0_rm_pin_bob_check(kingpin));
3176 pi_tlink_del_fini(pin);
3177 pr_tlink_del_fini(pin);
3185 m0_rm_ur_tlist_move(
3189 m0_rm_pin_bob_fini(pin);
3213 pr_tlist_add(&credit->
cr_pins, pin);
3215 m0_rm_pin_bob_init(pin);
3236 return A->cr_ops->cro_intersects(
A,
B);
3245 return A->cr_ops->cro_conflicts(
A,
B) ?
3288 M0_ENTRY(
"splitting credits %llu and %llu",
3289 (
long long unsigned)
src->cr_datum,
3290 (
long long unsigned)
diff->cr_datum);
3297 if (
rc != 0 && new_credit !=
NULL) {
3301 *remnant_credit = new_credit;
3318 if (credit !=
NULL) {
3327 *dest_credit = credit;
3338 dst->cr_group_id =
src->cr_group_id;
3384 (
long long unsigned) credit->
cr_datum);
3576 " after rc = %d with ep = %s",
3635 new_state =
obj->co_ha_state;
3639 rem_tracker.rht_clink);
3641 if (event ==
NULL) {
3646 event->rhe_state = new_state;
struct m0_rm_credit is_credit
const struct m0_rm_credit_ops * cr_ops
static int m0_rm_owner_trylock(struct m0_rm_owner *owner)
M0_INTERNAL int m0_rm_outgoing_init(struct m0_rm_outgoing *out, enum m0_rm_outgoing_type req_type, struct m0_rm_remote *other, struct m0_rm_credit *credit)
#define M0_BUFVEC_INIT_BUF(addr_ptr, count_ptr)
M0_INTERNAL int m0_rm_owner_selfadd(struct m0_rm_owner *owner, struct m0_rm_credit *r)
M0_INTERNAL int m0_rm_request_out(enum m0_rm_outgoing_type otype, struct m0_rm_incoming *in, struct m0_rm_loan *loan, struct m0_rm_credit *credit, struct m0_rm_remote *other)
M0_INTERNAL int m0_mutex_trylock(struct m0_mutex *mutex)
static void credit_processor(struct m0_rm_resource_type *rt)
static void incoming_queue(struct m0_rm_owner *owner, struct m0_rm_incoming *in)
struct m0_rm_resource * rem_resource
struct m0_rm_resource_type * r_type
static struct m0_addb2_philter p
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
void(* rio_conflict)(struct m0_rm_incoming *in)
bool(* rto_is)(const struct m0_rm_resource *resource, uint64_t id)
static int credit_diff(struct m0_rm_credit *c0, const struct m0_rm_credit *c1)
static struct m0_semaphore wait
static const struct m0_bob_type credit_bob
static bool rev_session_clink_cb(struct m0_clink *link)
M0_INTERNAL void m0_sm_fail(struct m0_sm *mach, int fail_state, int32_t rc)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
static struct m0_list list
enum m0_rm_remote_state rem_state
static int cancel_send(struct m0_rm_loan *loan)
M0_INTERNAL void m0_rm_ha_unsubscribe_lock(struct m0_rm_ha_tracker *tracker)
static int(* diff[M0_PARITY_CAL_ALGO_NR])(struct m0_parity_math *math, struct m0_buf *old, struct m0_buf *new, struct m0_buf *parity, uint32_t index)
int const char const void size_t int flags
M0_INTERNAL int m0_rm_owner_loan_debit(struct m0_rm_owner *owner, struct m0_rm_loan *paid_loan, struct m0_tl *list)
static void reserve_prio_set(struct m0_rm_reserve_prio *prio, m0_time_t timestamp, struct m0_rm_owner *owner)
struct m0_cookie ri_rem_owner_cookie
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
static bool owner_invariant(struct m0_rm_owner *owner)
enum m0_rm_incoming_type rin_type
M0_INTERNAL void m0_clink_del(struct m0_clink *link)
static void incoming_complete(struct m0_rm_incoming *in, int32_t rc)
bool(* cro_intersects)(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
struct m0_clink rem_rev_sess_clink
static struct m0_rm_remote creditor
struct m0_rm_remote * ro_creditor
bool res_tlist_is_empty(const struct m0_tl *list)
static bool rm_on_remote_death_cb(struct m0_clink *link)
static bool credit_is_reserved(const struct m0_rm_credit *cr)
int m0_thread_join(struct m0_thread *q)
static bool credit_intersects(const struct m0_rm_credit *A, const struct m0_rm_credit *B)
void(* rio_complete)(struct m0_rm_incoming *in, int32_t rc)
static int credit_maybe_track(struct m0_rm_incoming *in, struct m0_rm_credit *cr, bool notify, int *wait)
M0_INTERNAL const struct m0_cookie M0_COOKIE_NULL
M0_INTERNAL int m0_rm_credit_decode(struct m0_rm_credit *credit, struct m0_buf *buf)
static void pending_outgoing_send(struct m0_rm_owner *owner, struct m0_clink *link)
M0_INTERNAL bool m0_uint128_eq(const struct m0_uint128 *u0, const struct m0_uint128 *u1)
M0_INTERNAL struct m0_rm_resource_type * m0_rm_resource_type_lookup(const struct m0_rm_domain *dom, const uint64_t rtype_id)
#define M0_LOG(level,...)
static struct m0_queue * remote_to_queue(struct m0_rm_remote *remote)
struct m0_cookie ri_loan_cookie
struct m0_cookie rl_cookie
M0_INTERNAL const struct m0_bob_type loan_bob
enum m0_rm_incoming_policy rin_policy
M0_INTERNAL int m0_rm_credit_dup(const struct m0_rm_credit *src_credit, struct m0_rm_credit **dest_credit)
static bool m0_is_po2(uint64_t val)
static void windup_incoming_complete(struct m0_rm_incoming *in, int32_t rc)
struct m0_rm_ha_tracker rem_tracker
bool(* cro_conflicts)(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
struct m0_rm_incoming * rp_incoming
static void resource_get(struct m0_rm_resource *res)
static bool credit_group_conflict(const struct m0_uint128 *g1, const struct m0_uint128 *g2)
struct m0_rm_owner * is_owner
static void rm_remote_free(struct m0_ref *ref)
M0_INTERNAL uint8_t m0_fid_tget(const struct m0_fid *fid)
struct m0_queue rt_ha_events
M0_INTERNAL const char * m0_sm_state_name(const struct m0_sm *mach, int state)
M0_INTERNAL bool m0_clink_is_armed(const struct m0_clink *link)
static int remnant_loan_get(const struct m0_rm_loan *loan, const struct m0_rm_credit *credit, struct m0_rm_loan **remnant_loan)
M0_INTERNAL void m0_rm_domain_init(struct m0_rm_domain *dom)
#define m0_exists(var, nr,...)
static int outgoing_check(struct m0_rm_incoming *in, enum m0_rm_outgoing_type, struct m0_rm_credit *credit, struct m0_rm_remote *other)
M0_INTERNAL void m0_rm_remote_init(struct m0_rm_remote *rem, struct m0_rm_resource *res)
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
M0_INTERNAL void m0_chan_lock(struct m0_chan *ch)
#define container_of(ptr, type, member)
struct m0_rm_credit rin_want
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
struct m0_rpc_session * rem_session
bool m0_rm_ur_tlist_contains(const struct m0_tl *list, const struct m0_rm_credit *credit)
M0_INTERNAL int m0_fid_cmp(const struct m0_fid *fid0, const struct m0_fid *fid1)
static struct m0_rm_incoming * cr2in(const struct m0_rm_credit *cr)
static const struct m0_addb2_trace * busy[1000]
enum m0_ha_obj_state rhe_state
M0_INTERNAL bool m0_fid_is_set(const struct m0_fid *fid)
M0_INTERNAL int m0_rm_loan_init(struct m0_rm_loan *loan, const struct m0_rm_credit *credit, struct m0_rm_remote *creditor)
M0_BOB_DEFINE(M0_INTERNAL, &resource_bob, m0_rm_resource)
void(* cro_free)(struct m0_rm_credit *self)
M0_INTERNAL void m0_sm_group_fini(struct m0_sm_group *grp)
M0_INTERNAL int m0_rm_net_locate(struct m0_rm_credit *credit, struct m0_rm_remote *other)
M0_INTERNAL int m0_rm_credit_encode(struct m0_rm_credit *credit, struct m0_buf *buf)
struct m0_rm_owner * cr_owner
M0_INTERNAL int m0_rm_owner_timedwait(struct m0_rm_owner *owner, uint64_t state, const m0_time_t abs_timeout)
static bool conflict_exists(const struct m0_rm_credit *cr, const struct m0_rm_owner *owner)
struct m0_rm_credit is_debit
static bool owner_smgrp_is_locked(const struct m0_rm_owner *owner)
M0_INTERNAL int m0_sm_timedwait(struct m0_sm *mach, uint64_t states, m0_time_t deadline)
const struct m0_rm_resource_ops * r_ops
static bool incoming_invariant(const struct m0_rm_incoming *in)
static M0_UNUSED struct m0_rm_resource_type * rem_incoming_to_resource_type(struct m0_rm_remote_incoming *rem_in)
M0_INTERNAL void incoming_surrender(struct m0_rm_incoming *in)
static M0_UNUSED struct m0_rm_resource_type * credit_to_resource_type(struct m0_rm_credit *credit)
M0_INTERNAL int m0_rm_resource_encode(struct m0_rm_resource *res, struct m0_buf *buf)
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
static void ha_events_handle(struct m0_rm_resource_type *rt)
struct m0_rm_credit rl_credit
M0_INTERNAL void m0_rm_outgoing_send(struct m0_rm_outgoing *outgoing)
static int service_locate(struct m0_rm_resource_type *rtype, struct m0_rm_remote *rem)
M0_INTERNAL void m0_fid_set(struct m0_fid *fid, uint64_t container, uint64_t key)
M0_INTERNAL void m0_rpc_service_reverse_session_put(struct m0_rpc_session *sess)
M0_INTERNAL void m0_rm_ha_tracker_fini(struct m0_rm_ha_tracker *tracker)
void m0_ref_init(struct m0_ref *ref, int init_num, void(*release)(struct m0_ref *ref))
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL int m0_rm_loan_settle(struct m0_rm_owner *owner, struct m0_rm_loan *loan)
struct m0_rm_credit * rp_credit
static void incoming_release(struct m0_rm_incoming *in)
static void owner_windup_locked(struct m0_rm_owner *owner)
bool res_tlist_contains(const struct m0_tl *list, const struct m0_rm_resource *res)
static enum m0_rm_owner_state owner_state(const struct m0_rm_owner *owner)
static int loan_check(struct m0_rm_owner *owner, struct m0_tl *list, struct m0_rm_credit *rest)
bool(* cro_is_subset)(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
M0_INTERNAL void m0_rm_incoming_init(struct m0_rm_incoming *in, struct m0_rm_owner *owner, enum m0_rm_incoming_type type, enum m0_rm_incoming_policy policy, uint64_t flags)
static const struct m0_rm_incoming_ops windup_incoming_ops
#define M0_AMB(obj, ptr, field)
#define m0_tl_teardown(name, head, obj)
static bool incoming_is_complete(const struct m0_rm_incoming *in)
static bool owner_invariant_state(const struct m0_rm_owner *owner, struct owner_invariant_state *is)
static bool resource_type_invariant(const struct m0_rm_resource_type *rt)
struct m0_tl ro_incoming[M0_RM_REQUEST_PRIORITY_NR][OQS_NR]
static int cached_credits_remove(struct m0_rm_incoming *in)
static bool owner_is_liquidated(const struct m0_rm_owner *o)
M0_INTERNAL int m0_rm_remote_resource_locate(struct m0_rm_remote *rem)
struct m0_chan rem_signal
const struct m0_uint128 m0_rm_no_group
M0_INTERNAL void m0_chan_init(struct m0_chan *chan, struct m0_mutex *ch_guard)
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
static enum m0_rm_incoming_state incoming_state(const struct m0_rm_incoming *in)
#define M0_RM_REMOTE_PUT(remote)
M0_INTERNAL void m0_sm_group_init(struct m0_sm_group *grp)
M0_INTERNAL int m0_rpc_session_status(struct m0_rpc_session *session)
static void incoming_check(struct m0_rm_incoming *in)
M0_INTERNAL void m0_fid_tgenerate(struct m0_fid *fid, const uint8_t tid)
void(* rop_policy)(struct m0_rm_resource *resource, struct m0_rm_incoming *in)
M0_INTERNAL void m0_rm_owner_fini(struct m0_rm_owner *owner)
M0_INTERNAL void m0_rm_owner_init_rfid(struct m0_rm_owner *owner, const struct m0_uint128 *group, struct m0_rm_resource *res, struct m0_rm_remote *creditor)
m0_time_t m0_time_now(void)
#define INCOMING_CREDIT(in)
static struct m0_addb2_callback c
void m0_sm_state_set(struct m0_sm *mach, int state)
M0_INTERNAL int m0_rm_db_service_query(const char *name, struct m0_rm_remote *rem)
struct m0_tl ro_outgoing[OQS_NR]
M0_INTERNAL int m0_rm_credit_copy(struct m0_rm_credit *dst, const struct m0_rm_credit *src)
#define bob_of(ptr, type, field, bt)
static int resource_locate(struct m0_rm_resource_type *rtype, struct m0_rm_remote *rem)
void m0_thread_fini(struct m0_thread *q)
M0_INTERNAL void m0_queue_link_init(struct m0_queue_link *ql)
const struct m0_rm_incoming_ops * rin_ops
static struct m0_stob_domain * dom
static int loan_dup(const struct m0_rm_loan *src_loan, struct m0_rm_loan **dest_loan)
M0_INTERNAL void m0_bufvec_cursor_init(struct m0_bufvec_cursor *cur, const struct m0_bufvec *bvec)
static struct rectype rt[]
static void owner_finalisation_check(struct m0_rm_owner *owner)
static int cmp(const struct m0_ut_suite **s0, const struct m0_ut_suite **s1)
M0_INTERNAL void m0_clink_signal(struct m0_clink *clink)
void * m0_alloc(size_t size)
void(* rop_credit_init)(struct m0_rm_resource *resource, struct m0_rm_credit *credit)
struct m0_sm_group * sm_grp
M0_INTERNAL int m0_rm_pin_add(struct m0_rm_incoming *in, struct m0_rm_credit *credit, uint32_t flags)
static int cached_credits_hold(struct m0_rm_incoming *in)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
M0_INTERNAL bool m0_cookie_is_eq(const struct m0_cookie *cookie1, const struct m0_cookie *cookie2)
static void barrier_pins_del(struct m0_rm_incoming *in)
static void incoming_state_set(struct m0_rm_incoming *in, enum m0_rm_incoming_state state)
struct m0_pdclust_instance pi
static int revoke_send(struct m0_rm_incoming *in, struct m0_rm_loan *loan, struct m0_rm_credit *credit)
static struct m0_sm_group * owner_grp(const struct m0_rm_owner *owner)
M0_INTERNAL void m0_cookie_init(struct m0_cookie *cookie, const uint64_t *obj)
M0_INTERNAL void m0_clink_cleanup(struct m0_clink *link)
static void cached_credits_clear(struct m0_rm_owner *owner)
static void owner_fail(struct m0_rm_owner *owner, enum m0_rm_owner_state state, int rc)
static void windup_incoming_conflict(struct m0_rm_incoming *in)
static const struct m0_bob_type rem_bob
struct m0_rm_remote * rl_other
static bool resource_list_check(const struct m0_rm_resource *res, void *datum)
static struct m0_rm_resource * incoming_to_resource(struct m0_rm_incoming *in)
static struct m0_clink clink[RDWR_REQUEST_MAX]
static void owner_cleanup(struct m0_rm_owner *owner)
struct m0_rm_remote * rin_remote
M0_INTERNAL int granted_maybe_reserve(struct m0_rm_credit *granted, struct m0_rm_credit *to_cache)
M0_INTERNAL void m0_rm_resource_free(struct m0_rm_resource *res)
M0_INTERNAL void m0_chan_unlock(struct m0_chan *ch)
static void incoming_pins_del(struct m0_rm_incoming *in, uint32_t flags)
static const struct m0_sm_conf owner_conf
static const struct m0_bob_type outgoing_bob
int(* cro_disjoin)(struct m0_rm_credit *self, const struct m0_rm_credit *c1, struct m0_rm_credit *intersection)
static struct m0_sm_state_descr owner_states[]
M0_TL_DESCR_DEFINE(res, "resources",, struct m0_rm_resource, r_linkage, r_magix, M0_RM_RESOURCE_MAGIC, M0_RM_RESOURCE_HEAD_MAGIC)
M0_INTERNAL int m0_rm_revoke_commit(struct m0_rm_remote_incoming *rem_in)
enum m0_ha_obj_state rht_state
static void conflict_notify(struct m0_rm_credit *credit)
#define m0_forall(var, nr,...)
M0_INTERNAL struct m0_queue_link * m0_queue_get(struct m0_queue *q)
static const struct m0_bob_type incoming_bob
enum credit_queue is_phase
M0_INTERNAL void m0_rm_credit_put(struct m0_rm_incoming *in)
static bool owner_has_loans(struct m0_rm_owner *owner)
static void rm_remote_online_handler(struct m0_rm_remote *remote)
M0_INTERNAL void m0_rm_resource_add(struct m0_rm_resource_type *rtype, struct m0_rm_resource *res)
M0_INTERNAL int64_t m0_ref_read(const struct m0_ref *ref)
M0_INTERNAL void m0_rm_loan_fini(struct m0_rm_loan *loan)
M0_INTERNAL void m0_queue_put(struct m0_queue *q, struct m0_queue_link *ql)
#define M0_RM_REMOTE_GET(remote)
static int incoming_check_held(struct m0_rm_incoming *in, struct m0_rm_credit *rest, struct m0_rm_credit *held, int *wait, bool *cr_used)
static void resource_put(struct m0_rm_resource *res)
static int incoming_pin_nr(const struct m0_rm_incoming *in, uint32_t flags)
struct m0_rm_incoming ri_incoming
static void pin_del(struct m0_rm_pin *pin)
#define M0_FI_ENABLED(tag)
static bool credit_is_empty(const struct m0_rm_credit *credit)
M0_INTERNAL void m0_rm_credit_init(struct m0_rm_credit *credit, struct m0_rm_owner *owner)
M0_INTERNAL void m0_rm_remote_fini(struct m0_rm_remote *rem)
M0_INTERNAL void m0_sm_init(struct m0_sm *mach, const struct m0_sm_conf *conf, uint32_t state, struct m0_sm_group *grp)
static const struct m0_sm_conf inc_conf
#define M0_ALLOC_PTR(ptr)
M0_INTERNAL void m0_clink_add(struct m0_chan *chan, struct m0_clink *link)
static bool has_reserve_priority(struct m0_rm_incoming *in1, struct m0_rm_incoming *in2)
static void owner_state_set(struct m0_rm_owner *owner, enum m0_rm_owner_state state)
bool m0_rm_ur_tlist_is_empty(const struct m0_tl *list)
M0_INTERNAL void m0_rm_outgoing_complete(struct m0_rm_outgoing *og)
static void incoming_policy_apply(struct m0_rm_incoming *in)
static struct m0_rm_remote * remote
M0_INTERNAL void m0_rm_owner_windup(struct m0_rm_owner *owner)
M0_INTERNAL int m0_rm_loan_alloc(struct m0_rm_loan **loan, const struct m0_rm_credit *credit, struct m0_rm_remote *creditor)
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copyto(struct m0_bufvec_cursor *dcur, void *sdata, m0_bcount_t num_bytes)
struct m0_tl ro_owned[OWOS_NR]
static bool credit_conflicts(const struct m0_rm_credit *A, const struct m0_rm_credit *B)
M0_INTERNAL void m0_cookie_new(uint64_t *gen)
M0_INTERNAL void m0_sm_move(struct m0_sm *mach, int32_t rc, int state)
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
static bool owner_is_idle(const struct m0_rm_owner *o)
int(* cro_diff)(struct m0_rm_credit *self, const struct m0_rm_credit *c1)
M0_INTERNAL void m0_queue_init(struct m0_queue *q)
#define IS_IN_ARRAY(idx, array)
m0_bcount_t(* cro_len)(const struct m0_rm_credit *self)
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
static struct m0_bob_type resource_bob
M0_INTERNAL void m0_rm_incoming_fini(struct m0_rm_incoming *in)
struct m0_clink rht_conf_exp
const struct m0_rm_resource_type_ops * rt_ops
M0_INTERNAL void m0_rm_owner_unlock(struct m0_rm_owner *owner)
static int credit_reservation_check(struct m0_rm_incoming *in, struct m0_rm_credit *cr, int *wait)
M0_INTERNAL int m0_rm_type_register(struct m0_rm_domain *dom, struct m0_rm_resource_type *rt)
#define M0_UINT128(hi, lo)
M0_INTERNAL void m0_rm_owner_creditor_reset(struct m0_rm_owner *owner, struct m0_rm_remote *creditor)
static void owner_liquidate(struct m0_rm_owner *src_owner)
M0_INTERNAL void m0_rm_ha_tracker_init(struct m0_rm_ha_tracker *tracker, m0_chan_cb_t cb)
static const struct m0_bob_type pin_bob
void m0_remotes_tlist_del(struct m0_rm_remote *rem)
M0_TL_DEFINE(res, M0_INTERNAL, struct m0_rm_resource)
static void owner_balance(struct m0_rm_owner *o)
struct m0_cookie rem_cookie
M0_INTERNAL void m0_rm_owner_lock(struct m0_rm_owner *owner)
static bool credit_eq(const struct m0_rm_credit *c0, const struct m0_rm_credit *c1)
static bool pin_check(const void *bob)
static int remnant_credit_get(const struct m0_rm_credit *src, const struct m0_rm_credit *diff, struct m0_rm_credit **remnant_credit)
struct m0_uint128 cr_group_id
static int credit_pin_nr(const struct m0_rm_credit *credit, uint32_t flags)
M0_INTERNAL void m0_rm_type_deregister(struct m0_rm_resource_type *rt)
static bool reserve_prio_is_set(struct m0_rm_reserve_prio *prio)
M0_INTERNAL struct m0_rm_remote * m0_rm_remote_find(struct m0_rm_remote_incoming *rem_in)
M0_INTERNAL void m0_rm_credit_fini(struct m0_rm_credit *credit)
struct m0_uint128 ro_group_id
struct m0_uint128 ri_group_id
M0_INTERNAL void m0_queue_fini(struct m0_queue *q)
static int scan(struct scanner *s)
#define m0_tl_find(name, var, head,...)
M0_INTERNAL void m0_rm_owner_init(struct m0_rm_owner *owner, struct m0_fid *fid, const struct m0_uint128 *group, struct m0_rm_resource *res, struct m0_rm_remote *creditor)
#define m0_tl_for(name, head, obj)
M0_INTERNAL void m0_chan_fini_lock(struct m0_chan *chan)
static struct m0_sm_state_descr inc_states[]
struct m0_sm_group rt_sm_grp
static void incoming_policy_none(struct m0_rm_incoming *in)
int(* cro_decode)(struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)
M0_INTERNAL int m0_rm_borrow_commit(struct m0_rm_remote_incoming *rem_in)
M0_INTERNAL void internal_incoming_fini(struct m0_rm_incoming *in)
struct m0_mutex rt_queue_guard
struct m0_pdclust_src_addr src
struct m0_rm_reserve_prio rin_reserve
M0_INTERNAL void m0_bob_type_tlist_init(struct m0_bob_type *bt, const struct m0_tl_descr *td)
static int incoming_check_with(struct m0_rm_incoming *in, struct m0_rm_credit *credit)
M0_INTERNAL void m0_rm_domain_fini(struct m0_rm_domain *dom)
#define offsetof(typ, memb)
M0_INTERNAL bool m0_sm_group_is_locked(const struct m0_sm_group *grp)
M0_INTERNAL void m0_rm_resource_del(struct m0_rm_resource *res)
#define m0_tl_exists(name, var, head,...)
struct m0_rm_loan rog_want
#define RM_OWNER_LISTS_FOR(owner, expr)
static void rm_remote_death_handler(struct m0_rm_remote *remote)
static bool credit_invariant(const struct m0_rm_credit *credit, void *data)
int(* cro_encode)(struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)
M0_INTERNAL void m0_rm_credit_get(struct m0_rm_incoming *in)
struct m0_queue_link rhe_link
struct m0_rm_resource * ro_resource
struct m0_tl rt_resources
M0_INTERNAL struct m0_rm_resource * m0_rm_resource_find(const struct m0_rm_resource_type *rt, const struct m0_rm_resource *res)
#define m0_tl_forall(name, var, head,...)
M0_INTERNAL void m0_rm_outgoing_fini(struct m0_rm_outgoing *out)
#define M0_IMPOSSIBLE(fmt,...)
static int borrow_send(struct m0_rm_incoming *in, struct m0_rm_credit *credit)
M0_INTERNAL void m0_sm_fini(struct m0_sm *mach)