23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_RM 27 #include "fid/fid_xc.h" 251 #define R_RW(res) container_of(res, struct m0_rw_lockable, rwl_resource) 252 #define RW_XO(rw) (&M0_XCODE_OBJ(m0_fid_xc, (void *)(rw)->rwl_fid)) 253 #define CR_XO(cr) (&M0_XCODE_OBJ(&M0_XT_U64, (void *)&(cr)->cr_datum)) 283 lockable0 =
R_RW(resource0);
284 lockable1 =
R_RW(resource1);
303 lockable =
R_RW(resource);
337 if (lockable ==
NULL)
340 xo =
RW_XO(lockable);
365 lockable =
R_RW(resource);
382 return self->cr_datum != 0 && c1->
cr_datum != 0;
421 if (self->cr_datum > c1->
cr_datum) {
426 intersection->
cr_datum =
self->cr_datum;
440 dest->cr_datum =
self->cr_datum;
441 dest->cr_owner =
self->cr_owner;
442 dest->cr_ops =
self->cr_ops;
454 self->cr_datum = (
self->cr_datum > c1->
cr_datum) ?
476 return self->cr_datum <= c1->
cr_datum;
581 rtype->
rt_name =
"rw-lockable";
599 #undef M0_TRACE_SUBSYSTEM const struct m0_rm_credit_ops * cr_ops
M0_INTERNAL int m0_xcode_encdec(struct m0_xcode_obj *obj, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
const struct m0_xcode_type * xo_type
static int rwlock_cr_join(struct m0_rm_credit *self, const struct m0_rm_credit *c1)
int const char const void size_t int flags
static void rwlockable_resource_free(struct m0_rm_resource *resource)
bool(* cro_intersects)(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
static struct m0_rm_remote creditor
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
static struct io_request req
static bool rwlock_cr_intersects(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
static m0_bcount_t rwlockable_len(const struct m0_rm_resource *resource)
static int rwlock_cr_decode(struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)
const struct m0_rm_resource_type_ops rwlockable_type_ops
M0_INTERNAL void m0_rm_rwlock_req_init(struct m0_rm_incoming *req, struct m0_rm_owner *owner, const struct m0_rm_incoming_ops *ops, enum m0_rm_incoming_flags flags, enum m0_rm_rwlock_req_type type)
bool(* rto_eq)(const struct m0_rm_resource *resource0, const struct m0_rm_resource *resource1)
static int rwlock_cr_encode(struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)
M0_INTERNAL void m0_rm_domain_init(struct m0_rm_domain *dom)
M0_INTERNAL void m0_xcode_free_obj(struct m0_xcode_obj *obj)
static bool rwlock_cr_is_subset(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
M0_INTERNAL void m0_rw_lockable_fini(struct m0_rw_lockable *lockable)
struct m0_rm_resource rwl_resource
M0_INTERNAL int m0_xcode_length(struct m0_xcode_ctx *ctx)
const struct m0_rm_resource_ops * r_ops
M0_INTERNAL void m0_rm_rwlock_owner_init(struct m0_rm_owner *owner, struct m0_fid *fid, struct m0_rw_lockable *lockable, struct m0_rm_remote *creditor)
static void rwlock_cr_initial_capital(struct m0_rm_credit *self)
return M0_ERR(-EOPNOTSUPP)
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)
M0_INTERNAL void m0_rm_rwlock_owner_fini(struct m0_rm_owner *owner)
#define M0_FID_TINIT(type, container, key)
static void rwlock_cr_free(struct m0_rm_credit *self)
const struct m0_uint128 m0_rm_no_group
M0_INTERNAL void m0_rm_owner_fini(struct m0_rm_owner *owner)
M0_INTERNAL void m0_rw_lockable_init(struct m0_rw_lockable *lockable, const struct m0_fid *fid, struct m0_rm_domain *dom)
static int rwlockable_decode(struct m0_bufvec_cursor *cur, struct m0_rm_resource **resource)
static struct m0_stob_domain * dom
M0_INTERNAL void m0_rm_rwlock_req_fini(struct m0_rm_incoming *req)
M0_INTERNAL void m0_rw_lockable_type_deregister(struct m0_rm_resource_type *rtype)
void(* rop_credit_init)(struct m0_rm_resource *resource, struct m0_rm_credit *credit)
static bool rwlockable_equal(const struct m0_rm_resource *resource0, const struct m0_rm_resource *resource1)
const struct m0_fid M0_RWLOCK_FID
M0_INTERNAL int m0_rwlockable_domain_type_init(struct m0_rm_domain *rwl_dom, struct m0_rm_resource_type *rwl_rt)
const struct m0_rm_resource_ops rwlockable_ops
static bool rwlock_cr_conflicts(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
M0_INTERNAL void m0_rm_resource_add(struct m0_rm_resource_type *rtype, struct m0_rm_resource *res)
static bool rwlock_credit_invariant(const struct m0_rm_credit *rwlock_cr)
#define M0_ALLOC_PTR(ptr)
static int rwlockable_encode(struct m0_bufvec_cursor *cur, const struct m0_rm_resource *resource)
static int rwlock_cr_disjoin(struct m0_rm_credit *self, const struct m0_rm_credit *c1, struct m0_rm_credit *intersection)
const struct m0_fid * rwl_fid
M0_INTERNAL void m0_rm_incoming_fini(struct m0_rm_incoming *in)
const struct m0_rm_resource_type_ops * rt_ops
M0_INTERNAL int m0_rm_type_register(struct m0_rm_domain *dom, struct m0_rm_resource_type *rt)
static int rwlock_cr_copy(struct m0_rm_credit *dest, const struct m0_rm_credit *self)
#define M0_XCODE_OBJ(type, ptr)
static m0_bcount_t rwlock_cr_len(const struct m0_rm_credit *c0)
M0_INTERNAL void m0_xcode_ctx_init(struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj)
const struct m0_rm_credit_ops rwlock_credit_ops
M0_INTERNAL void m0_rm_type_deregister(struct m0_rm_resource_type *rt)
static void rwlockable_credit_init(struct m0_rm_resource *resource, struct m0_rm_credit *credit)
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)
M0_INTERNAL void m0_rwlockable_domain_type_fini(struct m0_rm_domain *rwl_dom, struct m0_rm_resource_type *rwl_rt)
static int rwlock_cr_diff(struct m0_rm_credit *self, const struct m0_rm_credit *c1)
const struct m0_xcode_type M0_XT_U64
M0_INTERNAL int m0_rw_lockable_type_register(struct m0_rm_domain *dom, struct m0_rm_resource_type *rtype)
M0_INTERNAL void m0_rm_domain_fini(struct m0_rm_domain *dom)
M0_INTERNAL void m0_rm_resource_del(struct m0_rm_resource *res)