Motr  M0
rdwr_test_bench.c File Reference
#include "ut/ut.h"
#include "lib/misc.h"
#include "lib/memory.h"
#include "lib/mutex.h"
#include "reqh/reqh.h"
#include "fop/fom_long_lock.h"
Include dependency graph for rdwr_test_bench.c:

Go to the source code of this file.

Data Structures

struct  test_min_max
 
struct  test_request
 

Enumerations

enum  tb_request_type { RQ_READ, RQ_WRITE, RQ_WAKE_UP, RQ_LAST }
 
enum  tb_request_phase { PH_REQ_LOCK = M0_FOM_PHASE_INIT, PH_GOT_LOCK = M0_FOPH_NR + 1 }
 

Functions

 M0_TL_DESCR_DECLARE (m0_lll, M0_EXTERN)
 
 M0_TL_DECLARE (m0_lll, M0_INTERNAL, struct m0_long_lock_link)
 
static bool readers_check (struct m0_long_lock *lock)
 
static bool writer_check (struct m0_long_lock *lock)
 
static bool lock_check (struct m0_long_lock *lock, enum tb_request_type type, size_t owners_min, size_t owners_max, size_t waiters)
 
static int fom_rdwr_tick (struct m0_fom *fom)
 
static void reqh_fop_handle (struct m0_reqh *reqh, struct m0_fom *fom)
 
static void test_req_handle (struct m0_reqh *reqh, struct test_request *rq, int seqn)
 
static void rdwr_send_fop (struct m0_reqh **reqh, size_t reqh_nr)
 

Variables

static struct m0_fomsleeper
 
static struct m0_chan chan [RDWR_REQUEST_MAX]
 
static struct m0_clink clink [RDWR_REQUEST_MAX]
 
static struct m0_long_lock long_lock
 
static struct test_request test [3][RDWR_REQUEST_MAX]
 

Enumeration Type Documentation

◆ tb_request_phase

Enumerator
PH_REQ_LOCK 
PH_GOT_LOCK 

Definition at line 39 of file rdwr_test_bench.c.

◆ tb_request_type

Enumerator
RQ_READ 
RQ_WRITE 
RQ_WAKE_UP 
RQ_LAST 

Definition at line 32 of file rdwr_test_bench.c.

Function Documentation

◆ fom_rdwr_tick()

static int fom_rdwr_tick ( struct m0_fom fom)
static

Definition at line 133 of file rdwr_test_bench.c.

Here is the call graph for this function:

◆ lock_check()

static bool lock_check ( struct m0_long_lock lock,
enum tb_request_type  type,
size_t  owners_min,
size_t  owners_max,
size_t  waiters 
)
static

Checks expected readers and writers against actual.

Definition at line 112 of file rdwr_test_bench.c.

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

◆ M0_TL_DECLARE()

M0_TL_DECLARE ( m0_lll  ,
M0_INTERNAL  ,
struct m0_long_lock_link   
)

◆ M0_TL_DESCR_DECLARE()

M0_TL_DESCR_DECLARE ( m0_lll  ,
M0_EXTERN   
)

◆ rdwr_send_fop()

static void rdwr_send_fop ( struct m0_reqh **  reqh,
size_t  reqh_nr 
)
static

Definition at line 296 of file rdwr_test_bench.c.

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

◆ readers_check()

static bool readers_check ( struct m0_long_lock lock)
static

a. Checks that multiple readers can hold the read lock concurrently, but writers (more than one) get blocked.

Definition at line 71 of file rdwr_test_bench.c.

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

◆ reqh_fop_handle()

static void reqh_fop_handle ( struct m0_reqh reqh,
struct m0_fom fom 
)
static

Definition at line 220 of file rdwr_test_bench.c.

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

◆ test_req_handle()

static void test_req_handle ( struct m0_reqh reqh,
struct test_request rq,
int  seqn 
)
static

Definition at line 229 of file rdwr_test_bench.c.

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

◆ writer_check()

static bool writer_check ( struct m0_long_lock lock)
static

b. Only one writer at a time can hold the write lock. All other contenders wait.

Definition at line 92 of file rdwr_test_bench.c.

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

Variable Documentation

◆ chan

struct m0_chan chan[RDWR_REQUEST_MAX]
static

Definition at line 63 of file rdwr_test_bench.c.

◆ clink

struct m0_clink clink[RDWR_REQUEST_MAX]
static

Definition at line 64 of file rdwr_test_bench.c.

◆ long_lock

struct m0_long_lock long_lock
static

Definition at line 65 of file rdwr_test_bench.c.

◆ sleeper

struct m0_fom* sleeper
static

Definition at line 62 of file rdwr_test_bench.c.

◆ test

struct test_request test[3][RDWR_REQUEST_MAX]
static

Definition at line 249 of file rdwr_test_bench.c.