Motr  M0
sync.c File Reference
#include "ut/ut.h"
#include "lib/tlist.h"
#include "lib/hash.h"
#include "mdservice/fsync_fops.h"
#include "lib/misc.h"
#include "reqh/reqh_service.h"
#include "motr/ut/client.h"
#include "motr/client_internal.h"
#include "motr/sync.h"
#include "motr/sync.c"
Include dependency graph for sync.c:

Go to the source code of this file.

Macros

#define NUM_STRECORDS   10
 

Functions

static int ut_post_rpc (struct m0_rpc_item *item)
 
static int ut_wait_for_reply (struct m0_rpc_item *item, m0_time_t timeout)
 
static void ut_fop_fini (struct m0_fop *fop)
 
static void ut_reset_stub_counters (void)
 
static void fake_setup (void)
 
static void ut_test_sync_request_fop_send (void)
 
void test_sync_reply_wait_init (struct sync_fop_wrapper *sfw, struct m0_reqh_service_txid *stx)
 
void call_sync_reply_wait (struct m0_client *input_cinst, struct m0_obj *input_obj, struct sync_fop_wrapper *input_sfw, int expect_return, int expect_ut_wait_for_reply_count, int expect_ut_fop_fini_count, uint64_t expect_txid, size_t expect_locality)
 
void ut_test_sync_reply_wait (void)
 
void ut_test_sync_record_update (void)
 
void call_sync_request_launch_and_wait (struct m0_obj *input_obj, int input_flag, int expect_return, int expect_ut_post_rpc_count, int expect_ut_wait_for_reply_count, int expect_ut_fop_fini_count)
 
static void ut_test_sync_request_launch_and_wait (void)
 
void call_m0_obj_sync (struct m0_obj *obj, int expect_return, int expect_ut_post_rpc_count, int expect_ut_fop_fini_count)
 
void ut_test_m0_obj_sync (void)
 
M0_INTERNAL int ut_sync_init (void)
 
M0_INTERNAL int ut_sync_fini (void)
 

Variables

struct m0_ut_suite ut_suite_sync
 
static int ut_post_rpc_count = 0
 
static int ut_wait_for_reply_count = 0
 
static int ut_fop_fini_count = 0
 
static int ut_post_rpc_delay = 0
 
static int ut_post_rpc_early_return = -EINVAL
 
static int ut_post_rpc_return = -EINVAL
 
static int ut_wait_for_reply_return = -EINVAL
 
static int ut_wait_for_reply_remote_return = 0
 
static struct m0_fop reply_fop
 
static struct m0_fop_fsync_rep reply_data
 
static struct sync_request sreq
 
static struct sync_target stgt
 
static struct m0_reqh_service_txid stx [NUM_STRECORDS]
 
static struct m0_reqh_service_txid sreq_stx [NUM_STRECORDS]
 
static struct sync_interactions copy
 
static struct m0_obj obj
 
static struct m0_client cinst
 
static struct m0_realm realm
 
static struct m0_rpc_conn conn = { .c_rpc_machine = (void*)1 }
 
static struct m0_reqh_service_ctx service
 
int default_txid = 42
 
int default_locality = 7
 

Macro Definition Documentation

◆ NUM_STRECORDS

#define NUM_STRECORDS   10

Definition at line 72 of file sync.c.

Function Documentation

◆ call_m0_obj_sync()

void call_m0_obj_sync ( struct m0_obj obj,
int  expect_return,
int  expect_ut_post_rpc_count,
int  expect_ut_fop_fini_count 
)

Definition at line 603 of file sync.c.

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

◆ call_sync_reply_wait()

void call_sync_reply_wait ( struct m0_client input_cinst,
struct m0_obj input_obj,
struct sync_fop_wrapper input_sfw,
int  expect_return,
int  expect_ut_wait_for_reply_count,
int  expect_ut_fop_fini_count,
uint64_t  expect_txid,
size_t  expect_locality 
)

Definition at line 310 of file sync.c.

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

◆ call_sync_request_launch_and_wait()

void call_sync_request_launch_and_wait ( struct m0_obj input_obj,
int  input_flag,
int  expect_return,
int  expect_ut_post_rpc_count,
int  expect_ut_wait_for_reply_count,
int  expect_ut_fop_fini_count 
)

Definition at line 500 of file sync.c.

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

◆ fake_setup()

static void fake_setup ( void  )
static

(Re-)initialises our fake Client instance. These are fed to the functions we test so that their container-of mechanisms find objects of the correct type, with our fake values.

Definition at line 167 of file sync.c.

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

◆ test_sync_reply_wait_init()

void test_sync_reply_wait_init ( struct sync_fop_wrapper sfw,
struct m0_reqh_service_txid stx 
)

Definition at line 285 of file sync.c.

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

◆ ut_fop_fini()

static void ut_fop_fini ( struct m0_fop fop)
static

Stub for fop_fini, frees any memory allocated to a fop, without the rpc_item reference counting getting upset that the fop was never sent/received.

Definition at line 140 of file sync.c.

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

◆ ut_post_rpc()

static int ut_post_rpc ( struct m0_rpc_item item)
static

Definition at line 95 of file sync.c.

Here is the caller graph for this function:

◆ ut_reset_stub_counters()

static void ut_reset_stub_counters ( void  )
static

Resets the stub counters.

Definition at line 152 of file sync.c.

Here is the caller graph for this function:

◆ ut_sync_fini()

M0_INTERNAL int ut_sync_fini ( void  )

Definition at line 657 of file sync.c.

◆ ut_sync_init()

M0_INTERNAL int ut_sync_init ( void  )

Definition at line 646 of file sync.c.

Here is the call graph for this function:

◆ ut_test_m0_obj_sync()

void ut_test_m0_obj_sync ( void  )

Definition at line 616 of file sync.c.

Here is the call graph for this function:

◆ ut_test_sync_record_update()

void ut_test_sync_record_update ( void  )

Tests the sync_record_update function.

Definition at line 472 of file sync.c.

Here is the call graph for this function:

◆ ut_test_sync_reply_wait()

void ut_test_sync_reply_wait ( void  )

Tests the sync_reply_wait function.

Definition at line 334 of file sync.c.

Here is the call graph for this function:

◆ ut_test_sync_request_fop_send()

static void ut_test_sync_request_fop_send ( void  )
static

Tests the sync_request_fop_send function.

Definition at line 224 of file sync.c.

Here is the call graph for this function:

◆ ut_test_sync_request_launch_and_wait()

static void ut_test_sync_request_launch_and_wait ( void  )
static

Tests the sync_launch_and_wait function.

Definition at line 522 of file sync.c.

Here is the call graph for this function:

◆ ut_wait_for_reply()

static int ut_wait_for_reply ( struct m0_rpc_item item,
m0_time_t  timeout 
)
static

Definition at line 109 of file sync.c.

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

Variable Documentation

◆ cinst

struct m0_client cinst
static

Definition at line 84 of file sync.c.

◆ conn

struct m0_rpc_conn conn = { .c_rpc_machine = (void*)1 }
static

Definition at line 90 of file sync.c.

◆ copy

struct sync_interactions copy
static

Definition at line 78 of file sync.c.

◆ default_locality

int default_locality = 7

Definition at line 282 of file sync.c.

◆ default_txid

int default_txid = 42

Definition at line 281 of file sync.c.

◆ obj

struct m0_obj obj
static

Definition at line 81 of file sync.c.

◆ realm

struct m0_realm realm
static

Definition at line 87 of file sync.c.

◆ reply_data

struct m0_fop_fsync_rep reply_data
static

Definition at line 65 of file sync.c.

◆ reply_fop

struct m0_fop reply_fop
static

Definition at line 62 of file sync.c.

◆ service

struct m0_reqh_service_ctx service
static

Definition at line 93 of file sync.c.

◆ sreq

struct sync_request sreq
static

Definition at line 68 of file sync.c.

◆ sreq_stx

struct m0_reqh_service_txid sreq_stx[NUM_STRECORDS]
static

Definition at line 74 of file sync.c.

◆ stgt

struct sync_target stgt
static

Definition at line 69 of file sync.c.

◆ stx

struct m0_reqh_service_txid stx[NUM_STRECORDS]
static

Definition at line 73 of file sync.c.

◆ ut_fop_fini_count

int ut_fop_fini_count = 0
static

Definition at line 52 of file sync.c.

◆ ut_post_rpc_count

int ut_post_rpc_count = 0
static

Definition at line 50 of file sync.c.

◆ ut_post_rpc_delay

int ut_post_rpc_delay = 0
static

Definition at line 55 of file sync.c.

◆ ut_post_rpc_early_return

int ut_post_rpc_early_return = -EINVAL
static

Definition at line 56 of file sync.c.

◆ ut_post_rpc_return

int ut_post_rpc_return = -EINVAL
static

Definition at line 57 of file sync.c.

◆ ut_suite_sync

struct m0_ut_suite ut_suite_sync
Initial value:
= {
.ts_name = "sync-ut",
.ts_init = ut_sync_init,
.ts_fini = ut_sync_fini,
.ts_tests = {
{ "m0_obj_sync",
{ "sync_request_launch_and_wait",
{ "sync_record_update",
{ "sync_reply_wait",
{ "sync_request_fop_send",
{ NULL, NULL },
}
}
#define NULL
Definition: misc.h:38
void ut_test_sync_record_update(void)
Definition: sync.c:472
M0_INTERNAL int ut_sync_init(void)
Definition: sync.c:646
void ut_test_m0_obj_sync(void)
Definition: sync.c:616
static void ut_test_sync_request_launch_and_wait(void)
Definition: sync.c:522
void ut_test_sync_reply_wait(void)
Definition: sync.c:334
M0_INTERNAL int ut_sync_fini(void)
Definition: sync.c:657
static void ut_test_sync_request_fop_send(void)
Definition: sync.c:224

Definition at line 47 of file sync.c.

◆ ut_wait_for_reply_count

int ut_wait_for_reply_count = 0
static

Definition at line 51 of file sync.c.

◆ ut_wait_for_reply_remote_return

int ut_wait_for_reply_remote_return = 0
static

Definition at line 59 of file sync.c.

◆ ut_wait_for_reply_return

int ut_wait_for_reply_return = -EINVAL
static

Definition at line 58 of file sync.c.