Motr  M0
item.c File Reference
#include "lib/trace.h"
#include "ut/ut.h"
#include "lib/finject.h"
#include "lib/fs.h"
#include "lib/misc.h"
#include "lib/semaphore.h"
#include "lib/memory.h"
#include "rpc/rpclib.h"
#include "rpc/ut/clnt_srv_ctx.c"
#include "rpc/ut/fops.h"
#include "rpc/rpc_internal.h"
Include dependency graph for item.c:

Go to the source code of this file.

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT
 
#define M0_UT_TRACE   0
 
#define IS_INCR_BY_N(p, n)   _0C(saved.rs_ ## p + (n) == stats.rs_ ## p)
 
#define IS_INCR_BY_1(p)   IS_INCR_BY_N(p, 1)
 

Enumerations

enum  { TIMEOUT = 4 }
 
enum  { M0_RPC_ITEM_CACHE_ITEMS_NR_MAX = 0x40 }
 

Functions

static int _test (void)
 
static void _test_timeout (m0_time_t deadline, m0_time_t timeout, bool reset)
 
static void _test_resend (struct m0_fop *fop, bool post_sync)
 
static void _test_timer_start_failure (void)
 
static void _ha_notify (struct m0_rpc_conn *conn, uint8_t state)
 
static void _ha_do_not_notify (struct m0_rpc_conn *conn, uint8_t state)
 
static int ts_item_init (void)
 
static int ts_item_fini (void)
 
static bool chk_state (const struct m0_rpc_item *item, enum m0_rpc_item_state state)
 
static void test_simple_transitions (void)
 
void disable_packet_ready_set_reply_error (int arg)
 
static void test_reply_item_error (void)
 
static void test_dropped (struct m0_rpc_item *item)
 
static void test_timeout (void)
 
static bool only_second_time (void *data)
 
static bool drop_twice (void *data)
 
static void test_resend (void)
 
static void test_failure_before_sending (void)
 
static void arrow_sent_cb (struct m0_rpc_item *item)
 
static void fop_release (struct m0_ref *ref)
 
static void test_oneway_item (void)
 
void fop_test (int expected_rc)
 
static void check_cancel (bool already_replied, bool reinitialise)
 
static void cancel_item_with_various_states (bool reinitialise)
 
static void test_cancel_item (void)
 
static void session_ut_item_cb (struct m0_rpc_item *item)
 
static void test_cancel_session (void)
 
static void test_item_cache_item_get (struct m0_rpc_item *item)
 
static void test_item_cache_item_put (struct m0_rpc_item *item)
 
static void test_item_cache_add_nth (struct m0_rpc_item_cache *ic, struct m0_mutex *lock, struct m0_rpc_item *items, int items_nr, int n)
 
static void test_item_cache (void)
 
void __ha_accept_imitate (struct m0_fid *sfid)
 
static void __ha_timer__dummy (struct m0_sm_timer *timer)
 
static bool __ha_service_event (struct m0_clink *link)
 
static void test_ha_cancel (void)
 
static void test_ha_notify ()
 

Variables

static enum m0_ha_obj_state expected_state
 
static struct m0_fid expected_fid
 
static struct m0_rpc_machinemachine
 
static struct m0_rpc_sessionsession
 
static struct m0_rpc_stats saved
 
static struct m0_rpc_stats stats
 
static struct m0_rpc_itemitem
 
static struct m0_fopfop
 
static int item_rc
 
static struct m0_rpc_item_type test_item_cache_itype
 
const struct m0_sm_conf outgoing_item_sm_conf
 
const struct m0_sm_conf incoming_item_sm_conf
 
void(* m0_rpc__item_dropped )(struct m0_rpc_item *item)
 
static struct m0_semaphore wait
 
static bool arrow_sent_cb_called = false
 
static const struct m0_rpc_item_ops arrow_item_ops
 
static bool fop_release_called
 
bool REINITIALISE_AFTER_CANCEL = true
 
bool ALREADY_REPLIED = true
 
uint32_t fop_dispatched_nr = 0
 
static const struct m0_rpc_item_ops session_ut_item_ops
 
static uint64_t test_item_cache_item_get_xid = UINT64_MAX - 1
 
static uint64_t test_item_cache_item_put_xid = UINT64_MAX - 1
 
static struct m0_rpc_item_type_ops test_item_cache_type_ops
 
static struct m0_thread ha_thread = {0}
 
m0_chan_cb_t rpc_conn_original_ha_cb = NULL
 
struct m0_ut_suite item_ut
 

Macro Definition Documentation

◆ IS_INCR_BY_1

#define IS_INCR_BY_1 (   p)    IS_INCR_BY_N(p, 1)

Definition at line 64 of file item.c.

◆ IS_INCR_BY_N

#define IS_INCR_BY_N (   p,
  n 
)    _0C(saved.rs_ ## p + (n) == stats.rs_ ## p)

Definition at line 63 of file item.c.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT

Definition at line 23 of file item.c.

◆ M0_UT_TRACE

#define M0_UT_TRACE   0

Definition at line 26 of file item.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TIMEOUT 

Definition at line 39 of file item.c.

◆ anonymous enum

anonymous enum
Enumerator
M0_RPC_ITEM_CACHE_ITEMS_NR_MAX 

Definition at line 912 of file item.c.

Function Documentation

◆ __ha_accept_imitate()

void __ha_accept_imitate ( struct m0_fid sfid)

Definition at line 1044 of file item.c.

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

◆ __ha_service_event()

static bool __ha_service_event ( struct m0_clink link)
static

Definition at line 1082 of file item.c.

Here is the caller graph for this function:

◆ __ha_timer__dummy()

static void __ha_timer__dummy ( struct m0_sm_timer timer)
static

Definition at line 1067 of file item.c.

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

◆ _ha_do_not_notify()

static void _ha_do_not_notify ( struct m0_rpc_conn conn,
uint8_t  state 
)
static

Definition at line 264 of file item.c.

Here is the caller graph for this function:

◆ _ha_notify()

static void _ha_notify ( struct m0_rpc_conn conn,
uint8_t  state 
)
static

Definition at line 268 of file item.c.

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

◆ _test()

static int _test ( void  )
static

Definition at line 519 of file item.c.

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

◆ _test_resend()

static void _test_resend ( struct m0_fop fop,
bool  post_sync 
)
static

Definition at line 425 of file item.c.

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

◆ _test_timeout()

static void _test_timeout ( m0_time_t  deadline,
m0_time_t  timeout,
bool  reset 
)
static

Definition at line 228 of file item.c.

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

◆ _test_timer_start_failure()

static void _test_timer_start_failure ( void  )
static

Definition at line 456 of file item.c.

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

◆ arrow_sent_cb()

static void arrow_sent_cb ( struct m0_rpc_item item)
static

Definition at line 539 of file item.c.

◆ cancel_item_with_various_states()

static void cancel_item_with_various_states ( bool  reinitialise)
static

Definition at line 708 of file item.c.

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

◆ check_cancel()

static void check_cancel ( bool  already_replied,
bool  reinitialise 
)
static

Definition at line 667 of file item.c.

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

◆ chk_state()

static bool chk_state ( const struct m0_rpc_item item,
enum m0_rpc_item_state  state 
)
static

Definition at line 85 of file item.c.

Here is the caller graph for this function:

◆ disable_packet_ready_set_reply_error()

void disable_packet_ready_set_reply_error ( int  arg)

Definition at line 115 of file item.c.

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

◆ drop_twice()

static bool drop_twice ( void *  data)
static

Definition at line 256 of file item.c.

Here is the caller graph for this function:

◆ fop_release()

static void fop_release ( struct m0_ref ref)
static

Definition at line 548 of file item.c.

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

◆ fop_test()

void fop_test ( int  expected_rc)

Definition at line 641 of file item.c.

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

◆ only_second_time()

static bool only_second_time ( void *  data)
static

Definition at line 248 of file item.c.

Here is the caller graph for this function:

◆ session_ut_item_cb()

static void session_ut_item_cb ( struct m0_rpc_item item)
static

Definition at line 823 of file item.c.

◆ test_cancel_item()

static void test_cancel_item ( void  )
static

Definition at line 802 of file item.c.

Here is the call graph for this function:

◆ test_cancel_session()

static void test_cancel_session ( void  )
static

Definition at line 832 of file item.c.

Here is the call graph for this function:

◆ test_dropped()

static void test_dropped ( struct m0_rpc_item item)
static

Definition at line 152 of file item.c.

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

◆ test_failure_before_sending()

static void test_failure_before_sending ( void  )
static

Definition at line 473 of file item.c.

Here is the call graph for this function:

◆ test_ha_cancel()

static void test_ha_cancel ( void  )
static

Definition at line 1093 of file item.c.

Here is the call graph for this function:

◆ test_ha_notify()

static void test_ha_notify ( void  )
static

Definition at line 1169 of file item.c.

Here is the call graph for this function:

◆ test_item_cache()

static void test_item_cache ( void  )
static

Definition at line 1003 of file item.c.

Here is the call graph for this function:

◆ test_item_cache_add_nth()

static void test_item_cache_add_nth ( struct m0_rpc_item_cache ic,
struct m0_mutex lock,
struct m0_rpc_item items,
int  items_nr,
int  n 
)
static

Definition at line 951 of file item.c.

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

◆ test_item_cache_item_get()

static void test_item_cache_item_get ( struct m0_rpc_item item)
static

Definition at line 919 of file item.c.

◆ test_item_cache_item_put()

static void test_item_cache_item_put ( struct m0_rpc_item item)
static

Definition at line 927 of file item.c.

◆ test_oneway_item()

static void test_oneway_item ( void  )
static

Definition at line 554 of file item.c.

Here is the call graph for this function:

◆ test_reply_item_error()

static void test_reply_item_error ( void  )
static

Definition at line 121 of file item.c.

Here is the call graph for this function:

◆ test_resend()

static void test_resend ( void  )
static

Definition at line 290 of file item.c.

Here is the call graph for this function:

◆ test_simple_transitions()

static void test_simple_transitions ( void  )
static

Definition at line 91 of file item.c.

Here is the call graph for this function:

◆ test_timeout()

static void test_timeout ( void  )
static

Definition at line 157 of file item.c.

Here is the call graph for this function:

◆ ts_item_fini()

static int ts_item_fini ( void  )
static

Definition at line 78 of file item.c.

Here is the call graph for this function:

◆ ts_item_init()

static int ts_item_init ( void  )
static

Definition at line 66 of file item.c.

Here is the call graph for this function:

Variable Documentation

◆ ALREADY_REPLIED

bool ALREADY_REPLIED = true

Definition at line 639 of file item.c.

◆ arrow_item_ops

const struct m0_rpc_item_ops arrow_item_ops
static
Initial value:
= {
.rio_sent = arrow_sent_cb,
}
static void arrow_sent_cb(struct m0_rpc_item *item)
Definition: item.c:539

Definition at line 543 of file item.c.

◆ arrow_sent_cb_called

bool arrow_sent_cb_called = false
static

Definition at line 538 of file item.c.

◆ expected_fid

struct m0_fid expected_fid
static

Definition at line 51 of file item.c.

◆ expected_state

enum m0_ha_obj_state expected_state
static

Definition at line 50 of file item.c.

◆ fop

struct m0_fop* fop
static

Definition at line 57 of file item.c.

◆ fop_dispatched_nr

uint32_t fop_dispatched_nr = 0

Definition at line 817 of file item.c.

◆ fop_release_called

bool fop_release_called
static

Definition at line 547 of file item.c.

◆ ha_thread

struct m0_thread ha_thread = {0}
static

Definition at line 1041 of file item.c.

◆ item

struct m0_rpc_item* item
static

Definition at line 56 of file item.c.

◆ item_rc

int item_rc
static

Definition at line 58 of file item.c.

◆ item_ut

struct m0_ut_suite item_ut
Initial value:
= {
.ts_name = "rpc-item-ut",
.ts_init = ts_item_init,
.ts_fini = ts_item_fini,
.ts_tests = {
{ "cache", test_item_cache },
{ "simple-transitions", test_simple_transitions },
{ "reply-item-error", test_reply_item_error },
{ "item-timeout", test_timeout },
{ "item-resend", test_resend },
{ "failure-before-sending", test_failure_before_sending },
{ "oneway-item", test_oneway_item },
{ "cancel", test_cancel_item },
{ "ha-cancel", test_ha_cancel },
{ "cancel-session", test_cancel_session },
{ "ha-notify", test_ha_notify },
{ NULL, NULL },
}
}
#define NULL
Definition: misc.h:38
static void test_item_cache(void)
Definition: item.c:1003
static int ts_item_fini(void)
Definition: item.c:78
static void test_ha_cancel(void)
Definition: item.c:1093
static void test_resend(void)
Definition: item.c:290
static void test_reply_item_error(void)
Definition: item.c:121
static void test_oneway_item(void)
Definition: item.c:554
static void test_ha_notify()
Definition: item.c:1169
static void test_failure_before_sending(void)
Definition: item.c:473
static void test_timeout(void)
Definition: item.c:157
static void test_cancel_session(void)
Definition: item.c:832
static int ts_item_init(void)
Definition: item.c:66
static void test_simple_transitions(void)
Definition: item.c:91
static void test_cancel_item(void)
Definition: item.c:802

Definition at line 1292 of file item.c.

◆ machine

struct m0_rpc_machine* machine
static

Definition at line 52 of file item.c.

◆ REINITIALISE_AFTER_CANCEL

bool REINITIALISE_AFTER_CANCEL = true

Definition at line 638 of file item.c.

◆ rpc_conn_original_ha_cb

m0_chan_cb_t rpc_conn_original_ha_cb = NULL

Definition at line 1042 of file item.c.

◆ saved

struct m0_rpc_stats saved
static

Definition at line 54 of file item.c.

◆ session

struct m0_rpc_session* session
static

Definition at line 53 of file item.c.

◆ session_ut_item_ops

const struct m0_rpc_item_ops session_ut_item_ops
static
Initial value:
= {
.rio_replied = session_ut_item_cb,
}
static void session_ut_item_cb(struct m0_rpc_item *item)
Definition: item.c:823

Definition at line 828 of file item.c.

◆ stats

struct m0_rpc_stats stats
static

Definition at line 55 of file item.c.

◆ test_item_cache_item_get_xid

uint64_t test_item_cache_item_get_xid = UINT64_MAX - 1
static

Definition at line 916 of file item.c.

◆ test_item_cache_item_put_xid

uint64_t test_item_cache_item_put_xid = UINT64_MAX - 1
static

Definition at line 917 of file item.c.

◆ test_item_cache_itype

static struct m0_rpc_item_type test_item_cache_itype
static
Initial value:
= {
}
static struct m0_rpc_item_type_ops test_item_cache_type_ops
Definition: item.c:938

Definition at line 59 of file item.c.

◆ test_item_cache_type_ops

struct m0_rpc_item_type_ops test_item_cache_type_ops
static
Initial value:
= {
.rito_item_get = test_item_cache_item_get,
.rito_item_put = test_item_cache_item_put,
}
static void test_item_cache_item_get(struct m0_rpc_item *item)
Definition: item.c:919
static void test_item_cache_item_put(struct m0_rpc_item *item)
Definition: item.c:927

Definition at line 938 of file item.c.

◆ wait

struct m0_semaphore wait
static

Definition at line 151 of file item.c.