Motr  M0
ms_fom_ut.c File Reference
#include "lib/errno.h"
#include "lib/memory.h"
#include "lib/semaphore.h"
#include "rpc/rpc_opcodes.h"
#include "fop/fom.h"
#include "fop/fom_generic.h"
#include "fop/fom_interpose.h"
#include "reqh/reqh.h"
#include "reqh/reqh_service.h"
#include "ut/ut.h"
Include dependency graph for ms_fom_ut.c:

Go to the source code of this file.

Data Structures

struct  ms_fom
 

Enumerations

enum  leader_fom_phase { START_FOLLOWER = M0_FOM_PHASE_INIT, FINISH = M0_FOM_PHASE_FINISH, CHECK_RESULT = M0_FOM_PHASE_NR }
 
enum  follower_fom_phase { FIRST_PHASE = M0_FOM_PHASE_INIT, FINISH_PHASE = M0_FOM_PHASE_FINISH, SECOND_PHASE = M0_FOM_PHASE_NR, THIRD_PHASE }
 

Functions

static size_t ms_fom_home_locality (const struct m0_fom *fom)
 
static int leader_fom_tick (struct m0_fom *fom)
 
static int follower_fom_tick (struct m0_fom *fom)
 
static void leader_fom_create (struct m0_fom **out, struct m0_reqh *reqh)
 
static void follower_fom_create (struct m0_fom **out, struct m0_reqh *reqh)
 
static void ms_fom_fini (struct m0_fom *fom)
 
static int mssvc_start (struct m0_reqh_service *svc)
 
static void mssvc_stop (struct m0_reqh_service *svc)
 
static void mssvc_fini (struct m0_reqh_service *svc)
 
static int mssvc_type_allocate (struct m0_reqh_service **svc, const struct m0_reqh_service_type *stype)
 
static void wakeup (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
static void fake_wait (struct ms_fom *fom)
 
static void ms_fom_create (struct m0_fom **out, struct m0_reqh *reqh, bool follower)
 
static void reqh_init (void)
 
static void reqh_start (void)
 
static void reqh_stop (void)
 
static void reqh_fini (void)
 
static void ms_init (void)
 
static void ms_fini (void)
 
static void leader_follower (void)
 
static void leader_follower_same_loc (void)
 
static void leader_follower_diff_loc (void)
 

Variables

static struct m0_sm_state_descr leader_fom_phases []
 
static struct m0_sm_state_descr follower_fom_phases []
 
static struct m0_sm_conf leader_sm_conf
 
static struct m0_sm_conf follower_sm_conf
 
static struct m0_fom_type leader_fomt
 
static struct m0_fom_type follower_fomt
 
static struct m0_semaphore sem
 
static struct m0_reqh msreqh
 
static struct m0_reqh_servicemssvc
 
uint64_t msfom_id = 0
 
struct m0_fom_thralldom thrall
 
static int test_counter
 
static bool use_same_locality = false
 
static const struct m0_reqh_service_ops mssvc_ops
 
static const struct m0_reqh_service_type_ops mssvc_type_ops
 
static struct m0_reqh_service_type ut_ms_service_type
 
static const struct m0_fom_ops leader_fom_ops
 
static const struct m0_fom_ops follower_fom_ops
 
const struct m0_fom_type_ops ms_fom_type_ops
 
struct m0_ut_suite ms_fom_ut
 

Enumeration Type Documentation

◆ follower_fom_phase

Enumerator
FIRST_PHASE 
FINISH_PHASE 
SECOND_PHASE 
THIRD_PHASE 

Definition at line 48 of file ms_fom_ut.c.

◆ leader_fom_phase

Enumerator
START_FOLLOWER 
FINISH 
CHECK_RESULT 

Definition at line 42 of file ms_fom_ut.c.

Function Documentation

◆ fake_wait()

static void fake_wait ( struct ms_fom fom)
static

Definition at line 210 of file ms_fom_ut.c.

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

◆ follower_fom_create()

static void follower_fom_create ( struct m0_fom **  out,
struct m0_reqh reqh 
)
static

Definition at line 300 of file ms_fom_ut.c.

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

◆ follower_fom_tick()

static int follower_fom_tick ( struct m0_fom fom)
static

Definition at line 245 of file ms_fom_ut.c.

Here is the call graph for this function:

◆ leader_follower()

static void leader_follower ( void  )
static

Definition at line 377 of file ms_fom_ut.c.

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

◆ leader_follower_diff_loc()

static void leader_follower_diff_loc ( void  )
static

Definition at line 396 of file ms_fom_ut.c.

Here is the call graph for this function:

◆ leader_follower_same_loc()

static void leader_follower_same_loc ( void  )
static

Definition at line 390 of file ms_fom_ut.c.

Here is the call graph for this function:

◆ leader_fom_create()

static void leader_fom_create ( struct m0_fom **  out,
struct m0_reqh reqh 
)
static

Definition at line 292 of file ms_fom_ut.c.

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

◆ leader_fom_tick()

static int leader_fom_tick ( struct m0_fom fom)
static

Definition at line 219 of file ms_fom_ut.c.

Here is the call graph for this function:

◆ ms_fini()

static void ms_fini ( void  )
static

Definition at line 367 of file ms_fom_ut.c.

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

◆ ms_fom_create()

static void ms_fom_create ( struct m0_fom **  out,
struct m0_reqh reqh,
bool  follower 
)
static

Definition at line 272 of file ms_fom_ut.c.

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

◆ ms_fom_fini()

static void ms_fom_fini ( struct m0_fom fom)
static

Definition at line 308 of file ms_fom_ut.c.

Here is the call graph for this function:

◆ ms_fom_home_locality()

static size_t ms_fom_home_locality ( const struct m0_fom fom)
static

Definition at line 196 of file ms_fom_ut.c.

Here is the call graph for this function:

◆ ms_init()

static void ms_init ( void  )
static

Definition at line 361 of file ms_fom_ut.c.

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

◆ mssvc_fini()

static void mssvc_fini ( struct m0_reqh_service svc)
static

Definition at line 149 of file ms_fom_ut.c.

Here is the call graph for this function:

◆ mssvc_start()

static int mssvc_start ( struct m0_reqh_service svc)
static

Definition at line 140 of file ms_fom_ut.c.

◆ mssvc_stop()

static void mssvc_stop ( struct m0_reqh_service svc)
static

Definition at line 145 of file ms_fom_ut.c.

◆ mssvc_type_allocate()

static int mssvc_type_allocate ( struct m0_reqh_service **  svc,
const struct m0_reqh_service_type stype 
)
static

Definition at line 154 of file ms_fom_ut.c.

◆ reqh_fini()

static void reqh_fini ( void  )
static

Definition at line 351 of file ms_fom_ut.c.

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

◆ reqh_init()

static void reqh_init ( void  )
static

Definition at line 321 of file ms_fom_ut.c.

Here is the caller graph for this function:

◆ reqh_start()

static void reqh_start ( void  )
static

Definition at line 332 of file ms_fom_ut.c.

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

◆ reqh_stop()

static void reqh_stop ( void  )
static

Definition at line 343 of file ms_fom_ut.c.

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

◆ wakeup()

static void wakeup ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

Definition at line 204 of file ms_fom_ut.c.

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

Variable Documentation

◆ follower_fom_ops

const struct m0_fom_ops follower_fom_ops
static
Initial value:
= {
.fo_fini = ms_fom_fini,
.fo_tick = follower_fom_tick,
.fo_home_locality = ms_fom_home_locality
}
static size_t ms_fom_home_locality(const struct m0_fom *fom)
Definition: ms_fom_ut.c:196
static int follower_fom_tick(struct m0_fom *fom)
Definition: ms_fom_ut.c:245
static void ms_fom_fini(struct m0_fom *fom)
Definition: ms_fom_ut.c:308

Ops object for follower fom

Definition at line 186 of file ms_fom_ut.c.

◆ follower_fom_phases

struct m0_sm_state_descr follower_fom_phases[]
static
Initial value:
= {
.sd_flags = M0_SDF_INITIAL,
.sd_name = "first-phase",
.sd_allowed = M0_BITS(SECOND_PHASE)
},
.sd_name = "second-phase",
.sd_allowed = M0_BITS(THIRD_PHASE)
},
.sd_name = "third-phase",
.sd_allowed = M0_BITS(FINISH_PHASE)
},
.sd_name = "finish-phase",
.sd_flags = M0_SDF_TERMINAL,
}
}
#define M0_BITS(...)
Definition: misc.h:236

Definition at line 71 of file ms_fom_ut.c.

◆ follower_fomt

struct m0_fom_type follower_fomt
static

Definition at line 104 of file ms_fom_ut.c.

◆ follower_sm_conf

struct m0_sm_conf follower_sm_conf
static
Initial value:
= {
.scf_name = "follower_fom",
.scf_nr_states = ARRAY_SIZE(follower_fom_phases),
.scf_state = follower_fom_phases,
}
static struct m0_sm_state_descr follower_fom_phases[]
Definition: ms_fom_ut.c:71
#define ARRAY_SIZE(a)
Definition: misc.h:45

Definition at line 97 of file ms_fom_ut.c.

◆ leader_fom_ops

const struct m0_fom_ops leader_fom_ops
static
Initial value:
= {
.fo_fini = ms_fom_fini,
.fo_tick = leader_fom_tick,
.fo_home_locality = ms_fom_home_locality
}
static size_t ms_fom_home_locality(const struct m0_fom *fom)
Definition: ms_fom_ut.c:196
static int leader_fom_tick(struct m0_fom *fom)
Definition: ms_fom_ut.c:219
static void ms_fom_fini(struct m0_fom *fom)
Definition: ms_fom_ut.c:308

Ops object for leader fom

Definition at line 180 of file ms_fom_ut.c.

◆ leader_fom_phases

struct m0_sm_state_descr leader_fom_phases[]
static
Initial value:
= {
.sd_flags = M0_SDF_INITIAL,
.sd_name = "start-follower",
.sd_allowed = M0_BITS(CHECK_RESULT)
},
.sd_name = "check-result",
.sd_allowed = M0_BITS(FINISH)
},
[FINISH] = {
.sd_name = "finish",
.sd_flags = M0_SDF_TERMINAL,
}
}
#define M0_BITS(...)
Definition: misc.h:236

Definition at line 55 of file ms_fom_ut.c.

◆ leader_fomt

struct m0_fom_type leader_fomt
static

Definition at line 103 of file ms_fom_ut.c.

◆ leader_sm_conf

struct m0_sm_conf leader_sm_conf
static
Initial value:
= {
.scf_name = "leader_fom",
.scf_nr_states = ARRAY_SIZE(leader_fom_phases),
.scf_state = leader_fom_phases,
}
static struct m0_sm_state_descr leader_fom_phases[]
Definition: ms_fom_ut.c:55
#define ARRAY_SIZE(a)
Definition: misc.h:45

Definition at line 91 of file ms_fom_ut.c.

◆ ms_fom_type_ops

const struct m0_fom_type_ops ms_fom_type_ops
Initial value:
= {
.fto_create = NULL
}
#define NULL
Definition: misc.h:38

Definition at line 192 of file ms_fom_ut.c.

◆ ms_fom_ut

struct m0_ut_suite ms_fom_ut
Initial value:
= {
.ts_name = "ms-fom-ut",
.ts_init = NULL,
.ts_fini = NULL,
.ts_tests = {
{ "leader-follower-sl", &leader_follower_same_loc, "Sergey" },
{ "leader-follower-dl", &leader_follower_diff_loc, "Sergey" },
{ NULL, NULL }
}
}
static void leader_follower_same_loc(void)
Definition: ms_fom_ut.c:390
#define NULL
Definition: misc.h:38
static void leader_follower_diff_loc(void)
Definition: ms_fom_ut.c:396

Definition at line 402 of file ms_fom_ut.c.

◆ msfom_id

uint64_t msfom_id = 0

Definition at line 109 of file ms_fom_ut.c.

◆ msreqh

struct m0_reqh msreqh
static

Definition at line 107 of file ms_fom_ut.c.

◆ mssvc

struct m0_reqh_service* mssvc
static

Definition at line 108 of file ms_fom_ut.c.

◆ mssvc_ops

const struct m0_reqh_service_ops mssvc_ops
static
Initial value:
= {
.rso_start = &mssvc_start,
.rso_stop = &mssvc_stop,
.rso_fini = &mssvc_fini
}
static int mssvc_start(struct m0_reqh_service *svc)
Definition: ms_fom_ut.c:140
int m0_reqh_service_async_start_simple(struct m0_reqh_service_start_async_ctx *asc)
Definition: reqh_service.c:601
static void mssvc_fini(struct m0_reqh_service *svc)
Definition: ms_fom_ut.c:149
static void mssvc_stop(struct m0_reqh_service *svc)
Definition: ms_fom_ut.c:145

Definition at line 133 of file ms_fom_ut.c.

◆ mssvc_type_ops

const struct m0_reqh_service_type_ops mssvc_type_ops
static
Initial value:
= {
.rsto_service_allocate = &mssvc_type_allocate
}
static int mssvc_type_allocate(struct m0_reqh_service **svc, const struct m0_reqh_service_type *stype)
Definition: ms_fom_ut.c:154

Definition at line 164 of file ms_fom_ut.c.

◆ sem

struct m0_semaphore sem
static

Definition at line 106 of file ms_fom_ut.c.

◆ test_counter

int test_counter
static

Definition at line 111 of file ms_fom_ut.c.

◆ thrall

struct m0_fom_thralldom thrall

Definition at line 110 of file ms_fom_ut.c.

◆ use_same_locality

bool use_same_locality = false
static

Definition at line 112 of file ms_fom_ut.c.

◆ ut_ms_service_type

struct m0_reqh_service_type ut_ms_service_type
static
Initial value:
= {
.rst_name = "ms_ut",
.rst_ops = &mssvc_type_ops,
.rst_level = M0_RS_LEVEL_NORMAL,
.rst_typecode = M0_CST_DS1
}
static const struct m0_reqh_service_type_ops mssvc_type_ops
Definition: ms_fom_ut.c:164

Definition at line 168 of file ms_fom_ut.c.