Motr  M0
Distributed RW Lock Internals
Collaboration diagram for Distributed RW Lock Internals:

Macros

#define R_RW(res)   container_of(res, struct m0_rw_lockable, rwl_resource)
 
#define RW_XO(rw)   (&M0_XCODE_OBJ(m0_fid_xc, (void *)(rw)->rwl_fid))
 
#define CR_XO(cr)   (&M0_XCODE_OBJ(&M0_XT_U64, (void *)&(cr)->cr_datum))
 

Functions

static bool rwlockable_equal (const struct m0_rm_resource *resource0, const struct m0_rm_resource *resource1)
 
static m0_bcount_t rwlockable_len (const struct m0_rm_resource *resource)
 
static int rwlockable_encode (struct m0_bufvec_cursor *cur, const struct m0_rm_resource *resource)
 
static int rwlockable_decode (struct m0_bufvec_cursor *cur, struct m0_rm_resource **resource)
 
static void rwlockable_credit_init (struct m0_rm_resource *resource, struct m0_rm_credit *credit)
 
static void rwlockable_resource_free (struct m0_rm_resource *resource)
 
static bool rwlock_cr_intersects (const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
 
static m0_bcount_t rwlock_cr_len (const struct m0_rm_credit *c0)
 
static int rwlock_cr_join (struct m0_rm_credit *self, const struct m0_rm_credit *c1)
 
static int rwlock_cr_disjoin (struct m0_rm_credit *self, const struct m0_rm_credit *c1, struct m0_rm_credit *intersection)
 
static int rwlock_cr_copy (struct m0_rm_credit *dest, const struct m0_rm_credit *self)
 
static int rwlock_cr_diff (struct m0_rm_credit *self, const struct m0_rm_credit *c1)
 
static bool rwlock_cr_conflicts (const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
 
static bool rwlock_cr_is_subset (const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
 
static int rwlock_cr_encode (struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)
 
static int rwlock_cr_decode (struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)
 
static void rwlock_cr_free (struct m0_rm_credit *self)
 
static void rwlock_cr_initial_capital (struct m0_rm_credit *self)
 
M0_INTERNAL int m0_rwlockable_domain_type_init (struct m0_rm_domain *rwl_dom, struct m0_rm_resource_type *rwl_rt)
 
M0_INTERNAL void m0_rwlockable_domain_type_fini (struct m0_rm_domain *rwl_dom, struct m0_rm_resource_type *rwl_rt)
 
static bool rwlock_credit_invariant (const struct m0_rm_credit *rwlock_cr)
 

Variables

const struct m0_rm_resource_type_ops rwlockable_type_ops
 
const struct m0_rm_resource_ops rwlockable_ops
 
const struct m0_rm_credit_ops rwlock_credit_ops
 

Detailed Description

This section contains the functions that are internal to the distributed RW lock. They implement various resource manager ops.

Credit structure

Credit for RW lock is represented by number of read locks permitted. Reader requires 1 such read lock, writer (exclusive access) requires all such read locks existing in the cluster.

Initial capacity of the credit owned by top-level creditor for RW lock resource type is ~0 read locks. It is assumed that number of read locks will be enough for any possible number of readers in the cluster.

If reader acquires RW lock then it requests credit for 0x01 read lock. Since number of read locks in the system is virtually infinite, all readers can hold RW lock simultaneously. If writer acquires RW lock then it requests credit for all (~0) read locks. So writer will exclusively own all the credits for RW lock and requests for this lock from other readers/writers won't be satisfied.

See also
Overview and Logical Specification

Macro Definition Documentation

◆ CR_XO

#define CR_XO (   cr)    (&M0_XCODE_OBJ(&M0_XT_U64, (void *)&(cr)->cr_datum))

Definition at line 253 of file rm_rwlock.c.

◆ R_RW

#define R_RW (   res)    container_of(res, struct m0_rw_lockable, rwl_resource)

Definition at line 251 of file rm_rwlock.c.

◆ RW_XO

#define RW_XO (   rw)    (&M0_XCODE_OBJ(m0_fid_xc, (void *)(rw)->rwl_fid))

Definition at line 252 of file rm_rwlock.c.

Function Documentation

◆ m0_rwlockable_domain_type_fini()

M0_INTERNAL void m0_rwlockable_domain_type_fini ( struct m0_rm_domain rwl_dom,
struct m0_rm_resource_type rwl_rt 
)

RW lockable domain and type finaliser.

Definition at line 267 of file rm_rwlock.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rwlockable_domain_type_init()

M0_INTERNAL int m0_rwlockable_domain_type_init ( struct m0_rm_domain rwl_dom,
struct m0_rm_resource_type rwl_rt 
)

RW lockable domain and type initialiser.

Definition at line 256 of file rm_rwlock.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rwlock_cr_conflicts()

static bool rwlock_cr_conflicts ( const struct m0_rm_credit self,
const struct m0_rm_credit c1 
)
static

Definition at line 460 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_cr_copy()

static int rwlock_cr_copy ( struct m0_rm_credit dest,
const struct m0_rm_credit self 
)
static

Definition at line 434 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_cr_decode()

static int rwlock_cr_decode ( struct m0_rm_credit self,
struct m0_bufvec_cursor cur 
)
static

Definition at line 486 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_cr_diff()

static int rwlock_cr_diff ( struct m0_rm_credit self,
const struct m0_rm_credit c1 
)
static

Definition at line 447 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_cr_disjoin()

static int rwlock_cr_disjoin ( struct m0_rm_credit self,
const struct m0_rm_credit c1,
struct m0_rm_credit intersection 
)
static

Definition at line 414 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_cr_encode()

static int rwlock_cr_encode ( struct m0_rm_credit self,
struct m0_bufvec_cursor cur 
)
static

Definition at line 479 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_cr_free()

static void rwlock_cr_free ( struct m0_rm_credit self)
static

Definition at line 492 of file rm_rwlock.c.

◆ rwlock_cr_initial_capital()

static void rwlock_cr_initial_capital ( struct m0_rm_credit self)
static

Definition at line 497 of file rm_rwlock.c.

◆ rwlock_cr_intersects()

static bool rwlock_cr_intersects ( const struct m0_rm_credit self,
const struct m0_rm_credit c1 
)
static

Definition at line 375 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_cr_is_subset()

static bool rwlock_cr_is_subset ( const struct m0_rm_credit self,
const struct m0_rm_credit c1 
)
static

Definition at line 471 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_cr_join()

static int rwlock_cr_join ( struct m0_rm_credit self,
const struct m0_rm_credit c1 
)
static

Definition at line 399 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_cr_len()

static m0_bcount_t rwlock_cr_len ( const struct m0_rm_credit c0)
static

Definition at line 385 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_credit_invariant()

static bool rwlock_credit_invariant ( const struct m0_rm_credit rwlock_cr)
static

Definition at line 370 of file rm_rwlock.c.

Here is the caller graph for this function:

◆ rwlockable_credit_init()

static void rwlockable_credit_init ( struct m0_rm_resource resource,
struct m0_rm_credit credit 
)
static

Definition at line 353 of file rm_rwlock.c.

◆ rwlockable_decode()

static int rwlockable_decode ( struct m0_bufvec_cursor cur,
struct m0_rm_resource **  resource 
)
static

Definition at line 326 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlockable_encode()

static int rwlockable_encode ( struct m0_bufvec_cursor cur,
const struct m0_rm_resource resource 
)
static

Encode lockable resource. Actually sending only RW lock FID is sufficient to reconstruct it on remote side

Definition at line 316 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlockable_equal()

static bool rwlockable_equal ( const struct m0_rm_resource resource0,
const struct m0_rm_resource resource1 
)
static

Compare identifiers of two lockable resources

Definition at line 275 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlockable_len()

static m0_bcount_t rwlockable_len ( const struct m0_rm_resource resource)
static

Definition at line 289 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlockable_resource_free()

static void rwlockable_resource_free ( struct m0_rm_resource resource)
static

Definition at line 361 of file rm_rwlock.c.

Here is the call graph for this function:

Variable Documentation

◆ rwlock_credit_ops

const struct m0_rm_credit_ops rwlock_credit_ops
Initial value:
= {
.cro_intersects = rwlock_cr_intersects,
.cro_join = rwlock_cr_join,
.cro_copy = rwlock_cr_copy,
.cro_diff = rwlock_cr_diff,
.cro_free = rwlock_cr_free,
.cro_encode = rwlock_cr_encode,
.cro_decode = rwlock_cr_decode,
.cro_len = rwlock_cr_len,
.cro_is_subset = rwlock_cr_is_subset,
.cro_disjoin = rwlock_cr_disjoin,
.cro_conflicts = rwlock_cr_conflicts,
.cro_initial_capital = rwlock_cr_initial_capital,
}
static int rwlock_cr_join(struct m0_rm_credit *self, const struct m0_rm_credit *c1)
Definition: rm_rwlock.c:399
static bool rwlock_cr_intersects(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
Definition: rm_rwlock.c:375
static int rwlock_cr_decode(struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)
Definition: rm_rwlock.c:486
static int rwlock_cr_encode(struct m0_rm_credit *self, struct m0_bufvec_cursor *cur)
Definition: rm_rwlock.c:479
static bool rwlock_cr_is_subset(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
Definition: rm_rwlock.c:471
static void rwlock_cr_initial_capital(struct m0_rm_credit *self)
Definition: rm_rwlock.c:497
static void rwlock_cr_free(struct m0_rm_credit *self)
Definition: rm_rwlock.c:492
static bool rwlock_cr_conflicts(const struct m0_rm_credit *self, const struct m0_rm_credit *c1)
Definition: rm_rwlock.c:460
static int rwlock_cr_disjoin(struct m0_rm_credit *self, const struct m0_rm_credit *c1, struct m0_rm_credit *intersection)
Definition: rm_rwlock.c:414
static int rwlock_cr_copy(struct m0_rm_credit *dest, const struct m0_rm_credit *self)
Definition: rm_rwlock.c:434
static m0_bcount_t rwlock_cr_len(const struct m0_rm_credit *c0)
Definition: rm_rwlock.c:385
static int rwlock_cr_diff(struct m0_rm_credit *self, const struct m0_rm_credit *c1)
Definition: rm_rwlock.c:447

Definition at line 236 of file rm_rwlock.c.

◆ rwlockable_ops

const struct m0_rm_resource_ops rwlockable_ops
Initial value:
= {
.rop_credit_init = rwlockable_credit_init,
.rop_resource_free = rwlockable_resource_free,
}
static void rwlockable_resource_free(struct m0_rm_resource *resource)
Definition: rm_rwlock.c:361
static void rwlockable_credit_init(struct m0_rm_resource *resource, struct m0_rm_credit *credit)
Definition: rm_rwlock.c:353

Definition at line 231 of file rm_rwlock.c.

◆ rwlockable_type_ops

const struct m0_rm_resource_type_ops rwlockable_type_ops
Initial value:
= {
.rto_eq = rwlockable_equal,
.rto_len = rwlockable_len,
.rto_decode = rwlockable_decode,
.rto_encode = rwlockable_encode,
}
static m0_bcount_t rwlockable_len(const struct m0_rm_resource *resource)
Definition: rm_rwlock.c:289
static int rwlockable_decode(struct m0_bufvec_cursor *cur, struct m0_rm_resource **resource)
Definition: rm_rwlock.c:326
static bool rwlockable_equal(const struct m0_rm_resource *resource0, const struct m0_rm_resource *resource1)
Definition: rm_rwlock.c:275
static int rwlockable_encode(struct m0_bufvec_cursor *cur, const struct m0_rm_resource *resource)
Definition: rm_rwlock.c:316

Definition at line 224 of file rm_rwlock.c.