Motr  M0
rm_rwlock.c File Reference
#include "lib/trace.h"
#include "lib/types.h"
#include "lib/chan.h"
#include "lib/misc.h"
#include "lib/memory.h"
#include "lib/time.h"
#include "lib/vec.h"
#include "fop/fom_generic.h"
#include "fid/fid.h"
#include "ut/ut.h"
#include "rm/rm.h"
#include "rm/rm_internal.h"
#include "rm/rm_rwlock.h"
#include "rm/ut/rmut.h"
Include dependency graph for rm_rwlock.c:

Go to the source code of this file.

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT
 
#define OWNER(srv_id)   rm_ctxs[srv_id].rc_test_data.rd_owner
 
#define INREQ(srv_id)   (&rm_ctxs[srv_id].rc_test_data.rd_in)
 

Functions

static void rwlockable_rtype_set (struct rm_ut_data *self)
 
static void rwlockable_rtype_unset (struct rm_ut_data *self)
 
static void rwlockable_res_set (struct rm_ut_data *self)
 
static void rwlockable_res_unset (struct rm_ut_data *self)
 
static void rwlock_owner_set (struct rm_ut_data *self)
 
static void rwlock_owner_unset (struct rm_ut_data *self)
 
static void rwlock_incoming_complete (struct m0_rm_incoming *in, int32_t rc)
 
static void rwlock_incoming_conflict (struct m0_rm_incoming *in)
 
static void rwlock_build_hierarchy (void)
 
static void rwlock_utinit (void)
 
static void rwlock_servers_windup (void)
 
static void rwlock_servers_disc_fini (void)
 
static void rwlock_utfini (void)
 
static void rwlock_acquire_nowait (enum rm_server srv, struct m0_rm_incoming *in, enum m0_rm_incoming_flags flags, enum m0_rm_rwlock_req_type req_type)
 
static void rwlock_req_wait (enum rm_server srv, struct m0_rm_incoming *in)
 
static void rwlock_acquire (enum rm_server srv, struct m0_rm_incoming *in, enum m0_rm_incoming_flags flags, enum m0_rm_rwlock_req_type req_type)
 
static void rwlock_release (struct m0_rm_incoming *in)
 
static void rwlock_encdec_test ()
 
void rwlock_read_test (void)
 
void rwlock_write_test (void)
 
void rwlock_read_read_hold_test (void)
 
void rwlock_read_write_hold_test (void)
 
void rwlock_write_read_hold_test1 (void)
 
void rwlock_write_read_hold_test2 (void)
 
void rwlock_write_write_hold_test (void)
 
void rwlock_two_read_locks_test (void)
 
void rwlock_writer_starvation_test (void)
 
void rwlock_read_read_sharing_test (void)
 

Variables

const struct m0_rm_resource_type_ops rwlockable_type_ops
 
static enum rm_server test_servers_nr
 
static struct m0_semaphore conflict_sem
 
static struct m0_semaphore waiting_sem
 
static const struct rm_ut_data_ops rwlock_ut_data_ops
 
const struct m0_rm_incoming_ops rwlock_incoming_ops
 
struct m0_ut_suite rm_rwlock_ut
 

Macro Definition Documentation

◆ INREQ

#define INREQ (   srv_id)    (&rm_ctxs[srv_id].rc_test_data.rd_in)

Definition at line 42 of file rm_rwlock.c.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT

Definition at line 23 of file rm_rwlock.c.

◆ OWNER

#define OWNER (   srv_id)    rm_ctxs[srv_id].rc_test_data.rd_owner

Definition at line 41 of file rm_rwlock.c.

Function Documentation

◆ rwlock_acquire()

static void rwlock_acquire ( enum rm_server  srv,
struct m0_rm_incoming in,
enum m0_rm_incoming_flags  flags,
enum m0_rm_rwlock_req_type  req_type 
)
static

Definition at line 233 of file rm_rwlock.c.

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

◆ rwlock_acquire_nowait()

static void rwlock_acquire_nowait ( enum rm_server  srv,
struct m0_rm_incoming in,
enum m0_rm_incoming_flags  flags,
enum m0_rm_rwlock_req_type  req_type 
)
static

Definition at line 209 of file rm_rwlock.c.

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

◆ rwlock_build_hierarchy()

static void rwlock_build_hierarchy ( void  )
static

Definition at line 140 of file rm_rwlock.c.

Here is the caller graph for this function:

◆ rwlock_encdec_test()

static void rwlock_encdec_test ( )
static

Definition at line 250 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_incoming_complete()

static void rwlock_incoming_complete ( struct m0_rm_incoming in,
int32_t  rc 
)
static

Definition at line 124 of file rm_rwlock.c.

◆ rwlock_incoming_conflict()

static void rwlock_incoming_conflict ( struct m0_rm_incoming in)
static

Definition at line 130 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_owner_set()

static void rwlock_owner_set ( struct rm_ut_data self)
static

Definition at line 92 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_owner_unset()

static void rwlock_owner_unset ( struct rm_ut_data self)
static

Definition at line 107 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_read_read_hold_test()

void rwlock_read_read_hold_test ( void  )

Definition at line 313 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_read_read_sharing_test()

void rwlock_read_read_sharing_test ( void  )

Definition at line 528 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_read_test()

void rwlock_read_test ( void  )

Definition at line 280 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_read_write_hold_test()

void rwlock_read_write_hold_test ( void  )

Definition at line 336 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_release()

static void rwlock_release ( struct m0_rm_incoming in)
static

Definition at line 244 of file rm_rwlock.c.

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

◆ rwlock_req_wait()

static void rwlock_req_wait ( enum rm_server  srv,
struct m0_rm_incoming in 
)
static

Definition at line 220 of file rm_rwlock.c.

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

◆ rwlock_servers_disc_fini()

static void rwlock_servers_disc_fini ( void  )
static

Definition at line 190 of file rm_rwlock.c.

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

◆ rwlock_servers_windup()

static void rwlock_servers_windup ( void  )
static

Definition at line 182 of file rm_rwlock.c.

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

◆ rwlock_two_read_locks_test()

void rwlock_two_read_locks_test ( void  )

Definition at line 455 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_utfini()

static void rwlock_utfini ( void  )
static

Definition at line 203 of file rm_rwlock.c.

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

◆ rwlock_utinit()

static void rwlock_utinit ( void  )
static

Definition at line 161 of file rm_rwlock.c.

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

◆ rwlock_write_read_hold_test1()

void rwlock_write_read_hold_test1 ( void  )

Definition at line 365 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_write_read_hold_test2()

void rwlock_write_read_hold_test2 ( void  )

Definition at line 394 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_write_test()

void rwlock_write_test ( void  )

Definition at line 297 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_write_write_hold_test()

void rwlock_write_write_hold_test ( void  )

Definition at line 425 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlock_writer_starvation_test()

void rwlock_writer_starvation_test ( void  )

Definition at line 487 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlockable_res_set()

static void rwlockable_res_set ( struct rm_ut_data self)
static

Definition at line 70 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlockable_res_unset()

static void rwlockable_res_unset ( struct rm_ut_data self)
static

Definition at line 81 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlockable_rtype_set()

static void rwlockable_rtype_set ( struct rm_ut_data self)
static

Definition at line 50 of file rm_rwlock.c.

Here is the call graph for this function:

◆ rwlockable_rtype_unset()

static void rwlockable_rtype_unset ( struct rm_ut_data self)
static

Definition at line 64 of file rm_rwlock.c.

Here is the call graph for this function:

Variable Documentation

◆ conflict_sem

struct m0_semaphore conflict_sem
static

Definition at line 47 of file rm_rwlock.c.

◆ rm_rwlock_ut

struct m0_ut_suite rm_rwlock_ut
Initial value:
= {
.ts_name = "rm-rwlock-ut",
.ts_tests = {
{ "rwlock-encdec" , rwlock_encdec_test },
{ "read-lock" , rwlock_read_test },
{ "read-lock-when-read-hold" , rwlock_read_read_hold_test },
{ "read-lock-when-write-hold" , rwlock_read_write_hold_test },
{ "write-lock" , rwlock_write_test },
{ "write-lock-when-read-hold1", rwlock_write_read_hold_test1 },
{ "write-lock-when-read-hold2", rwlock_write_read_hold_test2 },
{ "write-lock-when-write-hold", rwlock_write_write_hold_test },
{ "two-read-locks" , rwlock_two_read_locks_test },
{ "writer-starvation" , rwlock_writer_starvation_test },
{ "read-read-sharing" , rwlock_read_read_sharing_test },
{ NULL, NULL }
}
}
#define NULL
Definition: misc.h:38
void rwlock_write_read_hold_test1(void)
Definition: rm_rwlock.c:365
void rwlock_write_test(void)
Definition: rm_rwlock.c:297
void rwlock_read_read_sharing_test(void)
Definition: rm_rwlock.c:528
void rwlock_two_read_locks_test(void)
Definition: rm_rwlock.c:455
void rwlock_read_test(void)
Definition: rm_rwlock.c:280
void rwlock_write_read_hold_test2(void)
Definition: rm_rwlock.c:394
static void rwlock_encdec_test()
Definition: rm_rwlock.c:250
void rwlock_write_write_hold_test(void)
Definition: rm_rwlock.c:425
void rwlock_read_write_hold_test(void)
Definition: rm_rwlock.c:336
void rwlock_read_read_hold_test(void)
Definition: rm_rwlock.c:313
void rwlock_writer_starvation_test(void)
Definition: rm_rwlock.c:487

Definition at line 572 of file rm_rwlock.c.

◆ rwlock_incoming_ops

const struct m0_rm_incoming_ops rwlock_incoming_ops
Initial value:
= {
.rio_complete = rwlock_incoming_complete,
.rio_conflict = rwlock_incoming_conflict
}
static void rwlock_incoming_complete(struct m0_rm_incoming *in, int32_t rc)
Definition: rm_rwlock.c:124
static void rwlock_incoming_conflict(struct m0_rm_incoming *in)
Definition: rm_rwlock.c:130

Definition at line 135 of file rm_rwlock.c.

◆ rwlock_ut_data_ops

const struct rm_ut_data_ops rwlock_ut_data_ops
static
Initial value:
= {
.rtype_set = rwlockable_rtype_set,
.rtype_unset = rwlockable_rtype_unset,
.resource_set = rwlockable_res_set,
.resource_unset = rwlockable_res_unset,
.owner_set = rwlock_owner_set,
.owner_unset = rwlock_owner_unset,
.credit_datum_set = NULL
}
static void rwlockable_res_set(struct rm_ut_data *self)
Definition: rm_rwlock.c:70
#define NULL
Definition: misc.h:38
static void rwlockable_rtype_set(struct rm_ut_data *self)
Definition: rm_rwlock.c:50
static void rwlockable_res_unset(struct rm_ut_data *self)
Definition: rm_rwlock.c:81
static void rwlock_owner_unset(struct rm_ut_data *self)
Definition: rm_rwlock.c:107
static void rwlock_owner_set(struct rm_ut_data *self)
Definition: rm_rwlock.c:92
static void rwlockable_rtype_unset(struct rm_ut_data *self)
Definition: rm_rwlock.c:64

Definition at line 114 of file rm_rwlock.c.

◆ test_servers_nr

enum rm_server test_servers_nr
static

Definition at line 46 of file rm_rwlock.c.

◆ waiting_sem

struct m0_semaphore waiting_sem
static

Definition at line 48 of file rm_rwlock.c.