Motr
M0
|
#include <rm.h>
Data Fields | |
void(* | cro_free )(struct m0_rm_credit *self) |
int(* | cro_encode )(struct m0_rm_credit *self, struct m0_bufvec_cursor *cur) |
int(* | cro_decode )(struct m0_rm_credit *self, struct m0_bufvec_cursor *cur) |
m0_bcount_t(* | cro_len )(const struct m0_rm_credit *self) |
operations. | |
The following operations are implemented by resource type and used by generic code to analyse credits relationships. "0" means the empty credit in the following. | |
bool(* | cro_intersects )(const struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
bool(* | cro_is_subset )(const struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
int(* | cro_join )(struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
int(* | cro_disjoin )(struct m0_rm_credit *self, const struct m0_rm_credit *c1, struct m0_rm_credit *intersection) |
bool(* | cro_conflicts )(const struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
int(* | cro_diff )(struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
int(* | cro_copy )(struct m0_rm_credit *dst, const struct m0_rm_credit *self) |
void(* | cro_initial_capital )(struct m0_rm_credit *self) |
bool(* cro_conflicts) (const struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
True,iff | 'self credit' conflicts with c1. Credits conflict iff one of them authorises a usage incompatible with another. |
For example, R:[0, 100] conflicts with RW:[50, 150], because the latter authorises writes to bytes in the [50, 100] extent, which cannot be done while R:[0, 100] is held by some other owner.
"Conflicts" is assumed to satisfy the same conditions as "intersects" and, in addition,
- conflicts(A, B) => intersects(A, B), because if credits share nothing they cannot conflict. Note that this condition restricts possible resource semantics. For example, to satisfy it, a credit to write to a variable must always imply a credit to read it.
int(* cro_copy) (struct m0_rm_credit *dst, const struct m0_rm_credit *self) |
int(* cro_decode) (struct m0_rm_credit *self, struct m0_bufvec_cursor *cur) |
int(* cro_diff) (struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
Difference between credits.
The difference is a part of self that doesn't intersect with c1.
For example, diff(RW:[50, 150], R:[0, 100]) == RW:[101, 150].
X <= Y means that diff(X, Y) is 0. X >= Y means Y <= X.
Two credits are equal, X == Y, when X <= Y and Y <= X.
"Difference" must satisfy the following conditions:
- diff(A, A) == 0, - diff(A, 0) == A, - diff(0, A) == 0, - !intersects(diff(A, B), B), - diff(A, diff(A, B)) == diff(B, diff(B, A)).
diff(A, diff(A, B)) is called a "meet" of A and B, it's an intersection of credits A and B. The condition above ensures that meet(A, B) == meet(B, A),
- diff(A, B) == diff(A, meet(A, B)), - meet(A, meet(B, C)) == meet(meet(A, B), C), - meet(A, 0) == 0, meet(A, A) == A, &c., - meet(A, B) <= A, - (X <= A and X <= B) iff X <= meet(A, B), - intersects(A, B) iff meet(A, B) != 0.
This function destructively updates "self" in place.
int(* cro_disjoin) (struct m0_rm_credit *self, const struct m0_rm_credit *c1, struct m0_rm_credit *intersection) |
int(* cro_encode) (struct m0_rm_credit *self, struct m0_bufvec_cursor *cur) |
void(* cro_free) (struct m0_rm_credit *self) |
void(* cro_initial_capital) (struct m0_rm_credit *self) |
bool(* cro_intersects) (const struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
True,iff | 'self credit' intersects with c1. Credits intersect when there is some usage authorised by credit self and by credit c1. |
For example, a credit to read an extent [0, 100] (denoted R:[0, 100]) intersects with a credit to read or write an extent [50, 150], (denoted RW:[50, 150]) because they can be both used to read bytes in the extent [50, 100].
"Intersects" is assumed to satisfy the following conditions:
- intersects(A, B) iff intersects(B, A) (symmetrical), - (A != 0) iff intersects(A, A) (almost reflexive), - !intersects(A, 0)
bool(* cro_is_subset) (const struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
int(* cro_join) (struct m0_rm_credit *self, const struct m0_rm_credit *c1) |
m0_bcount_t(* cro_len) (const struct m0_rm_credit *self) |