Motr  M0
util.h File Reference
#include "iscservice/isc.h"
#include "rpc/rpc_machine.h"
Include dependency graph for util.h:

Go to the source code of this file.

Data Structures

struct  isc_req
 

Macros

#define __MOTR_ISCSERVICE_DEMO_UTIL_H__
 
#define LOG(_fmt, ...)   fprintf(stderr, "%s: %s():%d: "_fmt, prog, __func__, __LINE__, ##__VA_ARGS__)
 
#define ERR(_fmt, ...)   if (trace_level >= LOG_ERROR) LOG(_fmt, ##__VA_ARGS__)
 
#define ERRS(_fmt, ...)
 
#define DBG(_fmt, ...)   if (trace_level >= LOG_DEBUG) LOG(_fmt, ##__VA_ARGS__)
 
#define DBG2(_fmt, ...)   if (trace_level >= LOG_DEBUG2) LOG(_fmt, ##__VA_ARGS__)
 
#define CHECK_BSZ_ARGS(bsz, m0bs)
 

Enumerations

enum  isc_buffer_len { CBL_DEFAULT_MAX = M0_RPC_DEF_MAX_RPC_MSG_SIZE >> 2, CBL_DEFAULT_MIN = 256 }
 
enum  { LOG_ERROR = 0, LOG_DEBUG = 1, LOG_DEBUG2 = 2 }
 

Functions

int isc_init (struct m0_config *, struct m0_client **)
 
void isc_fini (struct m0_client *)
 
uint64_t isc_m0gs (struct m0_obj *, struct m0_client *)
 
int isc_req_prepare (struct isc_req *, struct m0_buf *args, const struct m0_fid *comp, struct m0_layout_io_plop *iopl, uint32_t reply_len)
 
int isc_req_send (struct isc_req *req)
 
void isc_req_fini (struct isc_req *req)
 
int alloc_segs (struct m0_bufvec *data, struct m0_indexvec *ext, struct m0_bufvec *attr, uint64_t bsz, uint32_t cnt)
 
void free_segs (struct m0_bufvec *data, struct m0_indexvec *ext, struct m0_bufvec *attr)
 
uint64_t set_exts (struct m0_indexvec *ext, uint64_t off, uint64_t bsz)
 

Variables

struct m0_realm uber_realm
 
struct m0_semaphore isc_sem
 
struct m0_list isc_reqs
 
bool m0trace_on
 
int trace_level
 
char * prog
 

Macro Definition Documentation

◆ __MOTR_ISCSERVICE_DEMO_UTIL_H__

#define __MOTR_ISCSERVICE_DEMO_UTIL_H__

Definition at line 25 of file util.h.

◆ CHECK_BSZ_ARGS

#define CHECK_BSZ_ARGS (   bsz,
  m0bs 
)
Value:
if ((bsz) < 1 || (bsz) % PAGE_SIZE) { \
ERR("bsz(%lu) must be multiple of %luK\n", (m0bs), PAGE_SIZE/1024); \
return -EINVAL; \
} \
if ((m0bs) < 1 || (m0bs) % (bsz)) { \
ERR("bsz(%lu) must divide m0bs(%lu)\n", (bsz), (m0bs)); \
return -EINVAL; \
}
#define PAGE_SIZE
Definition: lnet_ut.c:277

Definition at line 135 of file util.h.

◆ DBG

#define DBG (   _fmt,
  ... 
)    if (trace_level >= LOG_DEBUG) LOG(_fmt, ##__VA_ARGS__)

Definition at line 132 of file util.h.

◆ DBG2

#define DBG2 (   _fmt,
  ... 
)    if (trace_level >= LOG_DEBUG2) LOG(_fmt, ##__VA_ARGS__)

Definition at line 133 of file util.h.

◆ ERR

#define ERR (   _fmt,
  ... 
)    if (trace_level >= LOG_ERROR) LOG(_fmt, ##__VA_ARGS__)

Definition at line 129 of file util.h.

◆ ERRS

#define ERRS (   _fmt,
  ... 
)
Value:
LOG(_fmt ": %s\n", ##__VA_ARGS__, strerror(errno))
int trace_level
Definition: util.c:41

Definition at line 130 of file util.h.

◆ LOG

#define LOG (   _fmt,
  ... 
)    fprintf(stderr, "%s: %s():%d: "_fmt, prog, __func__, __LINE__, ##__VA_ARGS__)

Definition at line 127 of file util.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LOG_ERROR 
LOG_DEBUG 
LOG_DEBUG2 

Definition at line 121 of file util.h.

◆ isc_buffer_len

Enumerator
CBL_DEFAULT_MAX 

32K

CBL_DEFAULT_MIN 

Definition at line 41 of file util.h.

Function Documentation

◆ alloc_segs()

int alloc_segs ( struct m0_bufvec data,
struct m0_indexvec ext,
struct m0_bufvec attr,
uint64_t  bsz,
uint32_t  cnt 
)

Definition at line 75 of file util.c.

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

◆ free_segs()

void free_segs ( struct m0_bufvec data,
struct m0_indexvec ext,
struct m0_bufvec attr 
)

Definition at line 67 of file util.c.

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

◆ isc_fini()

void isc_fini ( struct m0_client )

Definition at line 281 of file util.c.

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

◆ isc_init()

int isc_init ( struct m0_config ,
struct m0_client **   
)

Initialise Motr-related stuff.

Definition at line 247 of file util.c.

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

◆ isc_m0gs()

uint64_t isc_m0gs ( struct m0_obj obj,
struct m0_client cinst 
)

Return parity group size for object.

Definition at line 49 of file util.c.

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

◆ isc_req_fini()

void isc_req_fini ( struct isc_req req)

Finalizes the request, including input and result buffers.

Definition at line 229 of file util.c.

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

◆ isc_req_prepare()

int isc_req_prepare ( struct isc_req ,
struct m0_buf args,
const struct m0_fid comp,
struct m0_layout_io_plop iopl,
uint32_t  reply_len 
)

Prepares a request using provided parameters.

Parameters
[in]argsHolds arguments for the computation.
[in]compThe unique fid associated with the computation.
[in]ioplIO plop associated with the request.
[in]reply_lenExpected length of reply buffer. This is allowed to be greater than the actual length of reply.

Definition at line 108 of file util.c.

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

◆ isc_req_send()

int isc_req_send ( struct isc_req req)

Sends a request asynchronously.

The request is added to the isc_reqs list maintaining the order by the object unit offset. On reply receipt, isc_sem(aphore) is up-ped. The received reply is populated at req->cir_result. The error code is returned at req->cir_rc.

Note: the isc_reqs list is unprotected, so all the requests should be sent from the same thread.

Definition at line 198 of file util.c.

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

◆ set_exts()

uint64_t set_exts ( struct m0_indexvec ext,
uint64_t  off,
uint64_t  bsz 
)

Definition at line 95 of file util.c.

Here is the caller graph for this function:

Variable Documentation

◆ isc_reqs

struct m0_list isc_reqs

Definition at line 44 of file util.c.

◆ isc_sem

struct m0_semaphore isc_sem

Definition at line 43 of file util.c.

◆ m0trace_on

bool m0trace_on

Definition at line 42 of file util.c.

◆ prog

char* prog

Definition at line 316 of file iscdemo.c.

◆ trace_level

int trace_level

Definition at line 41 of file util.c.

◆ uber_realm

struct m0_realm uber_realm

Definition at line 40 of file util.c.