Motr  M0
m0_rm_credit_ops Struct Reference

#include <rm.h>

Collaboration diagram for m0_rm_credit_ops:
Collaboration graph

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)
 

Detailed Description

Note
"self credit" in the comments below refers to the credit on which an operation is invoked.

Definition at line 532 of file rm.h.

Field Documentation

◆ cro_conflicts

bool(* cro_conflicts) (const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
Return values
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.

Definition at line 618 of file rm.h.

◆ cro_copy

int(* cro_copy) (struct m0_rm_credit *dst, const struct m0_rm_credit *self)

Creates a copy of "src" in "dst".

Precondition
dst is empty.

Definition at line 666 of file rm.h.

◆ cro_decode

int(* cro_decode) (struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)

De-serialises the credit of a resource from a buffer.

Definition at line 546 of file rm.h.

◆ cro_diff

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.

Definition at line 660 of file rm.h.

◆ cro_disjoin

int(* cro_disjoin) (struct m0_rm_credit *self, const struct m0_rm_credit *c1, struct m0_rm_credit *intersection)

Splits self into two parts - diff(self,c1) and intersection(self, c1) Destructively updates 'self credit' with diff(self, c1) and updates intersection with intersection of (self, c1)

Definition at line 597 of file rm.h.

◆ cro_encode

int(* cro_encode) (struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)

Serialises a credit of a resource into a buffer.

Definition at line 541 of file rm.h.

◆ cro_free

void(* cro_free) (struct m0_rm_credit *self)

Called when the generic code is about to free a credit. Type specific code releases any resources associated with the credit.

Definition at line 537 of file rm.h.

◆ cro_initial_capital

void(* cro_initial_capital) (struct m0_rm_credit *self)

Setup initial capital

Definition at line 671 of file rm.h.

◆ cro_intersects

bool(* cro_intersects) (const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
Return values
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)

Definition at line 579 of file rm.h.

◆ cro_is_subset

bool(* cro_is_subset) (const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
Return values
Trueif 'self credit' is subset (or proper subset) of c1.

Definition at line 584 of file rm.h.

◆ cro_join

int(* cro_join) (struct m0_rm_credit *self, const struct m0_rm_credit *c1)

Adjoins c1 to 'self credit', updating self in place to be the sum credit.

Definition at line 590 of file rm.h.

◆ cro_len

m0_bcount_t(* cro_len) (const struct m0_rm_credit *self)

Return the size of the credit's data.

Definition at line 551 of file rm.h.


The documentation for this struct was generated from the following file: