Motr  M0
Vectors

Data Structures

struct  m0_vec
 
struct  m0_vec_cursor
 
struct  m0_indexvec
 
struct  m0_bufvec
 
struct  m0_bufvec_cursor
 
struct  m0_ivec_cursor
 
struct  m0_0vec
 
struct  m0_ioseg
 
struct  m0_io_indexvec
 
struct  m0_io_indexvec_seq
 
struct  m0_indexvec_varr
 
struct  m0_ivec_varr_cursor
 

Macros

#define M0_BUFVEC_INIT_BUF(addr_ptr, count_ptr)
 
#define M0_BUFVEC_FOR2(c0, c1, frag)
 
#define M0_BUFVEC_ENDFOR2   } }
 

Functions

M0_INTERNAL int m0_0vec_page_add (struct m0_0vec *zvec, struct page *pg, m0_bindex_t index)
 
 M0_BASSERT (M0_SEG_SIZE==M0_0VEC_ALIGN)
 
static m0_bcount_t vec_count (const struct m0_vec *vec, uint32_t i)
 
M0_INTERNAL m0_bcount_t m0_vec_count (const struct m0_vec *vec)
 
M0_INTERNAL bool m0_vec_is_empty (const struct m0_vec *vec)
 
static bool m0_vec_cursor_invariant (const struct m0_vec_cursor *cur)
 
static void m0_vec_cursor_normalize (struct m0_vec_cursor *cur)
 
M0_INTERNAL void m0_vec_cursor_init (struct m0_vec_cursor *cur, const struct m0_vec *vec)
 
M0_INTERNAL bool m0_vec_cursor_move (struct m0_vec_cursor *cur, m0_bcount_t count)
 
M0_INTERNAL m0_bcount_t m0_vec_cursor_step (const struct m0_vec_cursor *cur)
 
M0_INTERNAL m0_bcount_t m0_vec_cursor_end (const struct m0_vec_cursor *cur)
 
static int bufvec_alloc (struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift, bool pack)
 
static int m0__bufvec_alloc (struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift)
 
M0_INTERNAL int m0_bufvec_empty_alloc (struct m0_bufvec *bufvec, uint32_t num_segs)
 
M0_INTERNAL int m0_bufvec_alloc (struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size)
 
M0_INTERNAL int m0_bufvec_extend (struct m0_bufvec *bufvec, uint32_t num_segs)
 
M0_INTERNAL int m0_bufvec_merge (struct m0_bufvec *dst_bufvec, struct m0_bufvec *src_bufvec)
 
M0_INTERNAL int m0__bufvec_dont_dump (struct m0_bufvec *bufvec)
 
M0_INTERNAL int m0_bufvec_alloc_aligned (struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift)
 
M0_INTERNAL int m0_bufvec_alloc_aligned_packed (struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift)
 
static void m0_bufvec__free (struct m0_bufvec *bufvec, bool free_bufs)
 
M0_INTERNAL void m0_bufvec_free (struct m0_bufvec *bufvec)
 
M0_INTERNAL void m0_bufvec_free2 (struct m0_bufvec *bufvec)
 
M0_INTERNAL void bufvec_free_aligned (struct m0_bufvec *bufvec, unsigned shift, bool pack)
 
M0_INTERNAL void m0_bufvec_free_aligned (struct m0_bufvec *bufvec, unsigned shift)
 
M0_INTERNAL void m0_bufvec_free_aligned_packed (struct m0_bufvec *bufvec, unsigned shift)
 
static uint32_t vec_pack (uint32_t nr, m0_bcount_t *cnt, m0_bindex_t *idx)
 
M0_INTERNAL uint32_t m0_bufvec_pack (struct m0_bufvec *bv)
 
M0_INTERNAL int m0_bufvec_splice (const struct m0_bufvec *bvec, m0_bcount_t nr, struct m0_buf *buf)
 
M0_INTERNAL uint32_t m0_indexvec_pack (struct m0_indexvec *iv)
 
M0_INTERNAL int m0_indexvec_alloc (struct m0_indexvec *ivec, uint32_t len)
 
M0_INTERNAL void m0_indexvec_free (struct m0_indexvec *ivec)
 
M0_INTERNAL void m0_bufvec_cursor_init (struct m0_bufvec_cursor *cur, const struct m0_bufvec *bvec)
 
M0_INTERNAL bool m0_bufvec_cursor_move (struct m0_bufvec_cursor *cur, m0_bcount_t count)
 
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_step (const struct m0_bufvec_cursor *cur)
 
M0_INTERNAL void * bufvec_cursor_addr (struct m0_bufvec_cursor *cur)
 
M0_INTERNAL void * m0_bufvec_cursor_addr (struct m0_bufvec_cursor *cur)
 
M0_INTERNAL bool m0_bufvec_cursor_align (struct m0_bufvec_cursor *cur, uint64_t alignment)
 
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copy (struct m0_bufvec_cursor *dcur, struct m0_bufvec_cursor *scur, m0_bcount_t num_bytes)
 
M0_INTERNAL int m0_bufvec_cursor_cmp (struct m0_bufvec_cursor *c0, struct m0_bufvec_cursor *c1)
 
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_prefix (struct m0_bufvec_cursor *c0, struct m0_bufvec_cursor *c1)
 
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copyto (struct m0_bufvec_cursor *dcur, void *sdata, m0_bcount_t num_bytes)
 
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copyfrom (struct m0_bufvec_cursor *scur, void *ddata, m0_bcount_t num_bytes)
 
M0_INTERNAL void m0_ivec_cursor_init (struct m0_ivec_cursor *cur, const struct m0_indexvec *ivec)
 
M0_INTERNAL bool m0_ivec_cursor_move (struct m0_ivec_cursor *cur, m0_bcount_t count)
 
M0_INTERNAL m0_bcount_t m0_ivec_cursor_step (const struct m0_ivec_cursor *cur)
 
M0_INTERNAL m0_bindex_t m0_ivec_cursor_index (const struct m0_ivec_cursor *cur)
 
M0_INTERNAL bool m0_ivec_cursor_move_to (struct m0_ivec_cursor *cur, m0_bindex_t dest)
 
M0_INTERNAL m0_bindex_t m0_ivec_cursor_conti (const struct m0_ivec_cursor *cur, m0_bindex_t dest)
 
M0_INTERNAL void m0_0vec_fini (struct m0_0vec *zvec)
 
static bool addr_is_4k_aligned (void *addr)
 
static bool m0_0vec_invariant (const struct m0_0vec *zvec)
 
M0_INTERNAL int m0_0vec_init (struct m0_0vec *zvec, uint32_t segs_nr)
 
M0_INTERNAL void m0_0vec_bvec_init (struct m0_0vec *zvec, const struct m0_bufvec *src, const m0_bindex_t *index)
 
M0_INTERNAL void m0_0vec_bufs_init (struct m0_0vec *zvec, void **bufs, const m0_bindex_t *index, const m0_bcount_t *counts, uint32_t segs_nr)
 
M0_INTERNAL int m0_0vec_cbuf_add (struct m0_0vec *zvec, const struct m0_buf *buf, const m0_bindex_t *index)
 
static void data_to_bufvec (struct m0_bufvec *src_buf, void **data, size_t *len)
 
M0_INTERNAL int m0_data_to_bufvec_copy (struct m0_bufvec_cursor *cur, void *data, size_t len)
 
M0_INTERNAL int m0_bufvec_to_data_copy (struct m0_bufvec_cursor *cur, void *data, size_t len)
 
M0_INTERNAL m0_bcount_t m0_bufvec_copy (struct m0_bufvec *dst, struct m0_bufvec *src, m0_bcount_t num_bytes)
 
M0_INTERNAL m0_bcount_t m0_io_count (const struct m0_io_indexvec *io_info)
 
static uint32_t ivec_nr_or_prepare (struct m0_indexvec *in, m0_bcount_t offset, int req, uint32_t bshift, struct m0_indexvec *out)
 
M0_INTERNAL int m0_indexvec_split (struct m0_indexvec *in, m0_bcount_t curr_pos, m0_bcount_t nb_len, uint32_t bshift, struct m0_indexvec *out)
 
M0_INTERNAL int m0_indexvec_wire2mem (struct m0_io_indexvec *wire_ivec, int max_frags_nr, uint32_t bshift, struct m0_indexvec *mem_ivec)
 
M0_INTERNAL int m0_indexvec_mem2wire (struct m0_indexvec *mem_ivec, int max_frags_nr, uint32_t bshift, struct m0_io_indexvec *wire_ivec)
 
M0_INTERNAL int m0_indexvec_universal_set (struct m0_indexvec *iv)
 
M0_INTERNAL bool m0_indexvec_is_universal (const struct m0_indexvec *iv)
 
M0_INTERNAL int m0_indexvec_varr_alloc (struct m0_indexvec_varr *ivec, uint32_t len)
 
M0_INTERNAL void m0_indexvec_varr_free (struct m0_indexvec_varr *ivec)
 
static void m0_ivec_varr_cursor_normalize (struct m0_ivec_varr_cursor *cur)
 
M0_INTERNAL void m0_ivec_varr_cursor_init (struct m0_ivec_varr_cursor *cur, struct m0_indexvec_varr *ivec)
 
M0_INTERNAL bool m0_ivec_varr_cursor_move (struct m0_ivec_varr_cursor *cur, m0_bcount_t count)
 
M0_INTERNAL m0_bcount_t m0_ivec_varr_cursor_step (const struct m0_ivec_varr_cursor *cur)
 
M0_INTERNAL m0_bindex_t m0_ivec_varr_cursor_index (const struct m0_ivec_varr_cursor *cur)
 
M0_INTERNAL bool m0_ivec_varr_cursor_move_to (struct m0_ivec_varr_cursor *cur, m0_bindex_t dest)
 
M0_INTERNAL m0_bindex_t m0_ivec_varr_cursor_conti (const struct m0_ivec_varr_cursor *cur, m0_bindex_t dest)
 
M0_INTERNAL int m0_bufvec_to_buf_copy (struct m0_buf *buf, const struct m0_bufvec *bvec)
 
M0_INTERNAL int m0_buf_to_bufvec_copy (struct m0_bufvec *bvec, const struct m0_buf *buf)
 
struct m0_vec M0_XCA_DOMAIN (rpc)
 

Variables

struct m0_vec_cursor M0_XCA_DOMAIN
 

Detailed Description

Macro Definition Documentation

◆ M0_BUFVEC_ENDFOR2

#define M0_BUFVEC_ENDFOR2   } }

Definition at line 439 of file vec.h.

◆ M0_BUFVEC_FOR2

#define M0_BUFVEC_FOR2 (   c0,
  c1,
  frag 
)
Value:
{ \
struct m0_bufvec_cursor *__c0 = (c0); \
struct m0_bufvec_cursor *__c1 = (c1); \
m0_bcount_t frag = 0; \
while (!(m0_bufvec_cursor_move(__c0, frag) | \
m0_bufvec_cursor_move(__c1, frag))) { \
#define min_check(a, b)
Definition: arith.h:88
M0_INTERNAL bool m0_bufvec_cursor_move(struct m0_bufvec_cursor *cur, m0_bcount_t count)
Definition: vec.c:574
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_step(const struct m0_bufvec_cursor *cur)
Definition: vec.c:581

Iterates over fragments of 2 bufvecs.

Bit-wise OR used below to ensure both cursors get moved without short-circuit logic.

Definition at line 429 of file vec.h.

◆ M0_BUFVEC_INIT_BUF

#define M0_BUFVEC_INIT_BUF (   addr_ptr,
  count_ptr 
)
Value:
(struct m0_bufvec){ \
.ov_vec = { \
.v_nr = 1, \
.v_count = (count_ptr), \
}, \
.ov_buf = (addr_ptr) \
}
Definition: vec.h:145

Initialize a m0_bufvec containing a single segment of the specified size. The intended usage is as follows:

void *addr;
m0_bcount_t buf_count;
struct m0_bufvec in = M0_BUFVEC_INIT_BUF(&addr, &buf_count);
buf_count = ...;
addr = ...;

Definition at line 165 of file vec.h.

Function Documentation

◆ addr_is_4k_aligned()

static bool addr_is_4k_aligned ( void *  addr)
static

Definition at line 803 of file vec.c.

Here is the caller graph for this function:

◆ bufvec_alloc()

static int bufvec_alloc ( struct m0_bufvec bufvec,
uint32_t  num_segs,
m0_bcount_t  seg_size,
unsigned  shift,
bool  pack 
)
static

Definition at line 139 of file vec.c.

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

◆ bufvec_cursor_addr()

M0_INTERNAL void* bufvec_cursor_addr ( struct m0_bufvec_cursor cur)

Definition at line 588 of file vec.c.

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

◆ bufvec_free_aligned()

M0_INTERNAL void bufvec_free_aligned ( struct m0_bufvec bufvec,
unsigned  shift,
bool  pack 
)

Definition at line 407 of file vec.c.

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

◆ data_to_bufvec()

static void data_to_bufvec ( struct m0_bufvec src_buf,
void **  data,
size_t *  len 
)
static

Initializes a m0_bufvec containing a single element of specified size

Definition at line 933 of file vec.c.

Here is the caller graph for this function:

◆ ivec_nr_or_prepare()

static uint32_t ivec_nr_or_prepare ( struct m0_indexvec in,
m0_bcount_t  offset,
int  req,
uint32_t  bshift,
struct m0_indexvec out 
)
static

Definition at line 1012 of file vec.c.

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

◆ m0_0vec_bufs_init()

M0_INTERNAL void m0_0vec_bufs_init ( struct m0_0vec zvec,
void **  bufs,
const m0_bindex_t indices,
const m0_bcount_t counts,
uint32_t  segs_nr 
)

Init the m0_0vec structure from array of buffers with indices and counts. This API does not copy data. Just pointers are copied.

Note
The m0_0vec struct should be allocated by user.
Parameters
zvecThe m0_0vec structure to be initialized.
bufsArray of IO buffers.
indicesArray of target object indices.
countsArray of buffer counts.
segs_nrNumber of segments contained in the buf array.
Postcondition
m0_0vec_invariant(zvec).

Definition at line 876 of file vec.c.

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

◆ m0_0vec_bvec_init()

M0_INTERNAL void m0_0vec_bvec_init ( struct m0_0vec zvec,
const struct m0_bufvec bufvec,
const m0_bindex_t indices 
)

Init the m0_0vec structure from given m0_bufvec structure and array of indices. This API does not copy data. Only pointers are copied.

Precondition
zvec != NULL && bufvec != NULL && indices != NULL.
Parameters
zvecThe m0_0vec structure to be initialized.
bufvecThe m0_bufvec containing buffer starting addresses and with number of buffers and their byte counts.
indicesTarget object indices to start the IO from.
Postcondition
m0_0vec_invariant(zvec).

Definition at line 853 of file vec.c.

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

◆ m0_0vec_cbuf_add()

M0_INTERNAL int m0_0vec_cbuf_add ( struct m0_0vec zvec,
const struct m0_buf buf,
const m0_bindex_t index 
)

Add a m0_buf structure at given target index to m0_0vec structure.

Note
The m0_0vec struct should be allocated by user.
Parameters
zvecThe m0_0vec structure to be initialized.
bufThe m0_buf structure containing starting address of buffer and number of bytes in buffer.
indexIndex of target object to start IO from.
Postcondition
m0_0vec_invariant(zvec).

Definition at line 903 of file vec.c.

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

◆ m0_0vec_fini()

M0_INTERNAL void m0_0vec_fini ( struct m0_0vec zvec)

Finalize a m0_0vec structure.

Parameters
Them0_0vec structure to be deallocated.
See also
m0_0vec_init().

Definition at line 794 of file vec.c.

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

◆ m0_0vec_init()

M0_INTERNAL int m0_0vec_init ( struct m0_0vec zvec,
uint32_t  segs_nr 
)

Initialize a pre-allocated m0_0vec structure.

Precondition
zvec != NULL.
Parameters
zvecThe m0_0vec structure to be initialized.
segs_nrNumber of segments in zero vector.
Postcondition
zvec->z_bvec.ov_buf != NULL && zvec->z_bvec.ov_vec.v_nr != 0 && zvec->z_bvec.ov_vec.v_count != NULL && zvec->z_index != NULL

Definition at line 826 of file vec.c.

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

◆ m0_0vec_invariant()

static bool m0_0vec_invariant ( const struct m0_0vec zvec)
static

Definition at line 808 of file vec.c.

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

◆ m0_0vec_page_add()

M0_INTERNAL int m0_0vec_page_add ( struct m0_0vec zvec,
struct page *  pg,
m0_bindex_t  index 
)

Add a struct page to contents of m0_0vec structure. Struct page is kernel representation of a buffer.

Note
The m0_0vec struct should be allocated by user.
Parameters
zvecThe m0_0vec struct to be initialized.
pagesArray of kernel pages.
indexThe target object offset for page.
Postcondition
++zvec->z_cursor.bc_vc.vc_seg

Definition at line 28 of file kvec.c.

Here is the call graph for this function:

◆ m0__bufvec_alloc()

static int m0__bufvec_alloc ( struct m0_bufvec bufvec,
uint32_t  num_segs,
m0_bcount_t  seg_size,
unsigned  shift 
)
static

Definition at line 205 of file vec.c.

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

◆ m0__bufvec_dont_dump()

M0_INTERNAL int m0__bufvec_dont_dump ( struct m0_bufvec bufvec)

Exclude all the buffers in this vector from core dump.

Make all its memory excluded from core dump.

Definition at line 331 of file vec.c.

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

◆ M0_BASSERT()

M0_BASSERT ( M0_SEG_SIZE  = =M0_0VEC_ALIGN)

◆ m0_buf_to_bufvec_copy()

M0_INTERNAL int m0_buf_to_bufvec_copy ( struct m0_bufvec bvec,
const struct m0_buf buf 
)

Copies data from m0_buf structure to m0_bufvec structure.

Parameters
[out]bvec- Pointer to m0_bufvec structure.
[in]buf- Pointer to m0_buf structure.
Return values
0on success else error codes

Definition at line 1315 of file vec.c.

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

◆ m0_bufvec__free()

static void m0_bufvec__free ( struct m0_bufvec bufvec,
bool  free_bufs 
)
static

Definition at line 380 of file vec.c.

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

◆ m0_bufvec_alloc()

M0_INTERNAL int m0_bufvec_alloc ( struct m0_bufvec bufvec,
uint32_t  num_segs,
m0_bcount_t  seg_size 
)

Allocates memory for a struct m0_bufvec. All segments are of equal size. The internal struct m0_vec is also allocated by this routine.

Precondition
num_segs > 0 && seg_size > 0
Parameters
bufvecPointer to buffer vector to be initialized.
num_segsNumber of memory segments.
seg_sizeSize of each segment.
Return values
0On success.
-errnoOn failure.
See also
m0_bufvec_free()

Definition at line 220 of file vec.c.

Here is the call graph for this function:

◆ m0_bufvec_alloc_aligned()

M0_INTERNAL int m0_bufvec_alloc_aligned ( struct m0_bufvec bufvec,
uint32_t  num_segs,
m0_bcount_t  seg_size,
unsigned  shift 
)

Allocates aligned memory as specified by shift value for a struct m0_bufvec. Currently in kernel mode it supports PAGE_SIZE alignment only.

Definition at line 355 of file vec.c.

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

◆ m0_bufvec_alloc_aligned_packed()

M0_INTERNAL int m0_bufvec_alloc_aligned_packed ( struct m0_bufvec bufvec,
uint32_t  num_segs,
m0_bcount_t  seg_size,
unsigned  shift 
)

Allocates aligned memory as specified by shift value for a struct m0_bufvec. In userspace mode used for allocation of large buffers contigously.

Definition at line 366 of file vec.c.

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

◆ m0_bufvec_copy()

M0_INTERNAL m0_bcount_t m0_bufvec_copy ( struct m0_bufvec dst,
struct m0_bufvec src,
m0_bcount_t  num_bytes 
)

Definition at line 983 of file vec.c.

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

◆ m0_bufvec_cursor_addr()

M0_INTERNAL void * m0_bufvec_cursor_addr ( struct m0_bufvec_cursor cur)

Return the buffer address at the cursor's current position.

Precondition
!m0_bufvec_cursor_move(cur, 0)
See also
m0_bufvec_cursor_copy()
Parameters
curPointer to the struct m0_bufvec_cursor.
Return values
Pointerinto buffer.

Definition at line 597 of file vec.c.

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

◆ m0_bufvec_cursor_align()

M0_INTERNAL bool m0_bufvec_cursor_align ( struct m0_bufvec_cursor cur,
uint64_t  alignment 
)

Advances the cursor with some count such that cursor will be aligned to "alignment". Return convention is same as m0_bufvec_cursor_move().

Definition at line 604 of file vec.c.

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

◆ m0_bufvec_cursor_cmp()

M0_INTERNAL int m0_bufvec_cursor_cmp ( struct m0_bufvec_cursor c0,
struct m0_bufvec_cursor c1 
)

Compares contents of cursors. Return value the same as in memcmp(3).

The positions of the cursors after the call are undefined.

Definition at line 639 of file vec.c.

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

◆ m0_bufvec_cursor_copy()

M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copy ( struct m0_bufvec_cursor dcur,
struct m0_bufvec_cursor scur,
m0_bcount_t  num_bytes 
)

Copy bytes from one buffer to another using cursors. Both cursors are advanced by the number of bytes copied.

Parameters
dcurPointer to the destination buffer cursor positioned appropriately.
scurPointer to the source buffer cursor positioned appropriately.
num_bytesThe number of bytes to copy.
Return values
bytes_copiedThe number of bytes actually copied. This will be equal to num_bytes only if there was adequate space in the buffers.

Definition at line 620 of file vec.c.

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

◆ m0_bufvec_cursor_copyfrom()

M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copyfrom ( struct m0_bufvec_cursor scur,
void *  ddata,
m0_bcount_t  num_bytes 
)

Copy data with specified size from a cursor.

Parameters
scurPointer to the source buffer cursor positioned appropriately.
ddataPointer to area where the data is to be copied to.
num_bytesThe number of bytes to copy.

Definition at line 692 of file vec.c.

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

◆ m0_bufvec_cursor_copyto()

M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copyto ( struct m0_bufvec_cursor dcur,
void *  sdata,
m0_bcount_t  num_bytes 
)

Copy data with specified size to a cursor.

Parameters
dcurPointer to the destination buffer cursor positioned appropriately.
sdataPointer to area where the data is to be copied from.
num_bytesThe number of bytes to copy.

Definition at line 677 of file vec.c.

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

◆ m0_bufvec_cursor_init()

M0_INTERNAL void m0_bufvec_cursor_init ( struct m0_bufvec_cursor cur,
const struct m0_bufvec bvec 
)

Initialize a struct m0_bufvec cursor.

Parameters
curPointer to the struct m0_bufvec_cursor.
bvecPointer to the struct m0_bufvec.

Definition at line 563 of file vec.c.

Here is the call graph for this function:

◆ m0_bufvec_cursor_move()

M0_INTERNAL bool m0_bufvec_cursor_move ( struct m0_bufvec_cursor cur,
m0_bcount_t  count 
)

Advance the cursor "count" bytes further through the buffer vector.

See also
m0_vec_cursor_move()
Parameters
curPointer to the struct m0_bufvec_cursor.
Returns
true, iff the end of the vector has been reached while moving. The cursor is in end of the vector position in this case.
false otherwise

Definition at line 574 of file vec.c.

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

◆ m0_bufvec_cursor_prefix()

M0_INTERNAL m0_bcount_t m0_bufvec_cursor_prefix ( struct m0_bufvec_cursor c0,
struct m0_bufvec_cursor c1 
)

Returns the length of the common prefix of 2 cursors.

The positions of the cursors after the call are undefined.

Definition at line 654 of file vec.c.

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

◆ m0_bufvec_cursor_step()

M0_INTERNAL m0_bcount_t m0_bufvec_cursor_step ( const struct m0_bufvec_cursor cur)

Return number of bytes that the cursor have to be moved to reach the next segment in its vector (or to move into end of the vector position, when the cursor is already at the last segment).

Precondition
!m0_bufvec_cursor_move(cur, 0)
See also
m0_vec_cursor_step()
Parameters
curPointer to the struct m0_bufvec_cursor.
Return values
Count

Definition at line 581 of file vec.c.

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

◆ m0_bufvec_empty_alloc()

M0_INTERNAL int m0_bufvec_empty_alloc ( struct m0_bufvec bufvec,
uint32_t  num_segs 
)

The same as m0_bufvec_alloc(), but doesn't allocate memory for segments.

Definition at line 213 of file vec.c.

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

◆ m0_bufvec_extend()

M0_INTERNAL int m0_bufvec_extend ( struct m0_bufvec bufvec,
uint32_t  num_segs 
)

Assumes that all segments are of equal size. All additional segments are of the size of the initial segment in bufvec. The internal struct m0_vec is also allocated by this routine.

Precondition
num_segs > 0
bufvec != NULL
bufvec->ov_buf != NULL
bufvec->ov_vec.v_nr > 0
Parameters
bufvecPointer to buffer vector to be extended.
num_segsNumber of memory segments by which bufvec is to be extended.

Definition at line 228 of file vec.c.

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

◆ m0_bufvec_free()

M0_INTERNAL void m0_bufvec_free ( struct m0_bufvec bufvec)

Frees the buffers pointed to by m0_bufvec.ov_buf and the m0_bufvec.ov_vec vector, using m0_free().

Parameters
bufvecPointer to the m0_bufvec.
See also
m0_bufvec_alloc()

Definition at line 395 of file vec.c.

Here is the call graph for this function:

◆ m0_bufvec_free2()

M0_INTERNAL void m0_bufvec_free2 ( struct m0_bufvec bufvec)

The same as m0_bufvec_free(), but doesn't free the buffers pointed by m0_bufvec->ov_buf[]. Only m0_bufvec structure is freed.

Definition at line 401 of file vec.c.

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

◆ m0_bufvec_free_aligned()

M0_INTERNAL void m0_bufvec_free_aligned ( struct m0_bufvec bufvec,
unsigned  shift 
)

Frees the buffers pointed to by m0_bufvec.ov_buf and the m0_bufvec.ov_vec vector, using m0_free_aligned().

Parameters
bufvecPointer to the m0_bufvec.
See also
m0_bufvec_alloc_aligned()

Definition at line 436 of file vec.c.

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

◆ m0_bufvec_free_aligned_packed()

M0_INTERNAL void m0_bufvec_free_aligned_packed ( struct m0_bufvec bufvec,
unsigned  shift 
)
See also
m0_bufvec_free_aligned(). in userspace mode used for allocation of large buffers contigously.

Definition at line 443 of file vec.c.

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

◆ m0_bufvec_merge()

M0_INTERNAL int m0_bufvec_merge ( struct m0_bufvec dst_bufvec,
struct m0_bufvec src_bufvec 
)

Merges the source bufvec to the destination bufvec. Assumes that all segments are of equal size. Does not allocate bufvec->ov_buf, but does pointer manipulation such that src_bufvec's ov_bufs are appended to dst_bufvec's ov_bufs.

Precondition
num_segs > 0 for both source and destination bufvecs
seg_size > 0 for both source and destination bufvecs
ov_buf != NULL for both source and destination bufvecs
src_bufvec != NULL, dst_bufvec != NULL
Parameters
dst_bufvecPointer to the destination buffer in which the new bufvec is to be merged.
src_bufvecPointer to the source buffer which is to be merged.

Definition at line 280 of file vec.c.

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

◆ m0_bufvec_pack()

M0_INTERNAL uint32_t m0_bufvec_pack ( struct m0_bufvec bufvec)

Packs buffers vector by squashing its contiguous or overlapping chunks.

Precondition
bufvec->ov_vec.v_nr > 0.
Returns
the number of squashed chunks.

Definition at line 480 of file vec.c.

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

◆ m0_bufvec_splice()

M0_INTERNAL int m0_bufvec_splice ( const struct m0_bufvec bvec,
m0_bcount_t  nr,
struct m0_buf buf 
)

Flattens first nr bytes of a buffer vector into one buffer.

Definition at line 491 of file vec.c.

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

◆ m0_bufvec_to_buf_copy()

M0_INTERNAL int m0_bufvec_to_buf_copy ( struct m0_buf buf,
const struct m0_bufvec bvec 
)

Copies data from m0_bufvec structure to m0_buf structure.

Parameters
[out]buf- Pointer to m0_buf structure.
[in]bvec- Pointer to m0_bufvec structure.
Return values
0on success else error codes

Definition at line 1301 of file vec.c.

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

◆ m0_bufvec_to_data_copy()

M0_INTERNAL int m0_bufvec_to_data_copy ( struct m0_bufvec_cursor cur,
void *  data,
size_t  len 
)

Definition at line 964 of file vec.c.

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

◆ m0_data_to_bufvec_copy()

M0_INTERNAL int m0_data_to_bufvec_copy ( struct m0_bufvec_cursor cur,
void *  data,
size_t  len 
)

Helper functions to copy opaque data with specified size to and from a m0_bufvec

Definition at line 946 of file vec.c.

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

◆ m0_indexvec_alloc()

M0_INTERNAL int m0_indexvec_alloc ( struct m0_indexvec ivec,
uint32_t  len 
)

Allocate memory for index array and counts array in index vector.

Parameters
lenNumber of elements to allocate memory for.
Precondition
ivec != NULL && len > 0.
Postcondition
ivec->iv_index != NULL && ivec->iv_vec.v_count != NULL && ivec->iv_vec.v_nr == len.
ergo(retval == -ENOMEM, ivec->iv_index == NULL)

Definition at line 532 of file vec.c.

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

◆ m0_indexvec_free()

M0_INTERNAL void m0_indexvec_free ( struct m0_indexvec ivec)

Deallocates the memory buffers pointed to by index array and counts array. Also sets the array count to zero. If ivec->iv_index == NULL - does nothing.

Precondition
ivec != NULL.
Postcondition
ivec->iv_index == NULL && ivec->iv_vec.v_count == NULL && ivec->iv_vec.v_nr == 0.

Definition at line 553 of file vec.c.

Here is the caller graph for this function:

◆ m0_indexvec_is_universal()

M0_INTERNAL bool m0_indexvec_is_universal ( const struct m0_indexvec iv)

Returns true if the input indexvec is universal.

Definition at line 1129 of file vec.c.

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

◆ m0_indexvec_mem2wire()

M0_INTERNAL int m0_indexvec_mem2wire ( struct m0_indexvec mem_ivec,
int  max_frags_nr,
uint32_t  bshift,
struct m0_io_indexvec wire_ivec 
)

Definition at line 1087 of file vec.c.

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

◆ m0_indexvec_pack()

M0_INTERNAL uint32_t m0_indexvec_pack ( struct m0_indexvec ivec)

Packs index vector by squashing its contiguous or overlapping chunks.

Precondition
ivec->iv_vec.v_nr > 0.
Returns
the number of squashed chunks.

Definition at line 521 of file vec.c.

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

◆ m0_indexvec_split()

M0_INTERNAL int m0_indexvec_split ( struct m0_indexvec in,
m0_bcount_t  curr_pos,
m0_bcount_t  nb_len,
uint32_t  bshift,
struct m0_indexvec out 
)

Function to split the indexvec from the given offset to the lenth specified.

Parameters
mem_ivecIndexvec memory format.
curr_posStart position for new indexvec.
nb_lenSize of the data for new indexvec.
bshiftShift value for the data to align index vecs.
Precondition
in != NULL
out != NULL

Definition at line 1039 of file vec.c.

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

◆ m0_indexvec_universal_set()

M0_INTERNAL int m0_indexvec_universal_set ( struct m0_indexvec iv)

Creates an indexvec with a single extent, which spans the range [0. ~0). Since the range spanned by this indexvec represents union of all possible ranges that any indexvec can hold, it is referred as a universal indexvec.

Parameters
ivInput indexvec.

Definition at line 1116 of file vec.c.

Here is the call graph for this function:

◆ m0_indexvec_varr_alloc()

M0_INTERNAL int m0_indexvec_varr_alloc ( struct m0_indexvec_varr ivec,
uint32_t  len 
)

Allocates memory in m0_varr for index array and counts array in index vector.

Parameters
lenNumber of elements to allocate memory for.
Precondition
ivec != NULL && len > 0. return 0 iff memory allocation succeeds. -ENOMEM on failure.

Definition at line 1136 of file vec.c.

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

◆ m0_indexvec_varr_free()

M0_INTERNAL void m0_indexvec_varr_free ( struct m0_indexvec_varr ivec)

Deallocates the memory buffers in m0_varr.

Precondition
ivec != NULL.

Definition at line 1160 of file vec.c.

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

◆ m0_indexvec_wire2mem()

M0_INTERNAL int m0_indexvec_wire2mem ( struct m0_io_indexvec wire_ivec,
int  max_frags_nr,
uint32_t  bshift,
struct m0_indexvec mem_ivec 
)

Function to convert the on-wire indexvec to in-memory indexvec format. Since m0_io_indexvec (on-wire structure) and m0_indexvec (in-memory structures are different, conversion is needed.

Parameters
wire_ivecIndexvec wire format.
mem_ivecIndexvec memory format.
max_frags_nrNumber of fragments from the wire_ivec.
Precondition
wire_ive != NULL
mem_ivec != NULL

Definition at line 1058 of file vec.c.

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

◆ m0_io_count()

M0_INTERNAL m0_bcount_t m0_io_count ( const struct m0_io_indexvec io_info)

Definition at line 999 of file vec.c.

Here is the caller graph for this function:

◆ m0_ivec_cursor_conti()

M0_INTERNAL m0_bindex_t m0_ivec_cursor_conti ( const struct m0_ivec_cursor cur,
m0_bindex_t  dest 
)

Returns the latest index through the contiguous segments up to .

Precondition
dest >= m0_ivec_cursor_index(cur).
Parameters
curcursor to start from.
destuptil where to check.

Definition at line 765 of file vec.c.

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

◆ m0_ivec_cursor_index()

M0_INTERNAL m0_bindex_t m0_ivec_cursor_index ( const struct m0_ivec_cursor cur)

Returns index at current cursor position.

Parameters
curGiven index vector cursor.

Definition at line 733 of file vec.c.

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

◆ m0_ivec_cursor_init()

M0_INTERNAL void m0_ivec_cursor_init ( struct m0_ivec_cursor cur,
const struct m0_indexvec ivec 
)

Initialize given index vector cursor.

Parameters
curGiven index vector cursor.
ivecGiven index vector to be associated with cursor.

Definition at line 707 of file vec.c.

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

◆ m0_ivec_cursor_move()

M0_INTERNAL bool m0_ivec_cursor_move ( struct m0_ivec_cursor cur,
m0_bcount_t  count 
)

Moves the index vector cursor forward by .

Parameters
curGiven index vector cursor.
countCount by which cursor has to be moved. true iff end of vector has been reached while moving cursor by . Returns false otherwise.

Definition at line 718 of file vec.c.

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

◆ m0_ivec_cursor_move_to()

M0_INTERNAL bool m0_ivec_cursor_move_to ( struct m0_ivec_cursor cursor,
m0_bindex_t  dest 
)

Moves index vector cursor forward until it reaches index .

Precondition
dest >= m0_ivec_cursor_index(cursor).
Parameters
destIndex uptil which cursor has to be moved. true iff end of vector has been reached while moving cursor. Returns false otherwise.

Definition at line 745 of file vec.c.

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

◆ m0_ivec_cursor_step()

M0_INTERNAL m0_bcount_t m0_ivec_cursor_step ( const struct m0_ivec_cursor cur)

Returns the number of bytes needed to move cursor to next segment in given index vector.

Parameters
curIndex vector to be moved.

Definition at line 726 of file vec.c.

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

◆ m0_ivec_varr_cursor_conti()

M0_INTERNAL m0_bindex_t m0_ivec_varr_cursor_conti ( const struct m0_ivec_varr_cursor cur,
m0_bindex_t  dest 
)

Returns the latest index through the contiguous segments up to .

Precondition
dest >= m0_ivec_varr_cursor_index(cur).
Parameters
curcursor to start from.
destuptil where to check.

Definition at line 1271 of file vec.c.

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

◆ m0_ivec_varr_cursor_index()

M0_INTERNAL m0_bindex_t m0_ivec_varr_cursor_index ( const struct m0_ivec_varr_cursor cur)

Returns index at current cursor position.

Parameters
curGiven index vector cursor. Index at current cursor position.

Definition at line 1237 of file vec.c.

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

◆ m0_ivec_varr_cursor_init()

M0_INTERNAL void m0_ivec_varr_cursor_init ( struct m0_ivec_varr_cursor cur,
struct m0_indexvec_varr ivec 
)

Initializes given index vector cursor.

Parameters
curGiven index vector cursor.
ivecGiven index vector to be associated with cursor.

Definition at line 1183 of file vec.c.

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

◆ m0_ivec_varr_cursor_move()

M0_INTERNAL bool m0_ivec_varr_cursor_move ( struct m0_ivec_varr_cursor cur,
m0_bcount_t  count 
)

Moves the index vector cursor forward by .

Parameters
curGiven index vector cursor.
countCount by which cursor has to be moved. true iff end of vector has been reached while moving cursor by . Returns false otherwise.

Definition at line 1198 of file vec.c.

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

◆ m0_ivec_varr_cursor_move_to()

M0_INTERNAL bool m0_ivec_varr_cursor_move_to ( struct m0_ivec_varr_cursor cur,
m0_bindex_t  dest 
)

Moves index vector cursor forward until it reaches index .

Precondition
dest >= m0_ivec_cursor_index(cursor).
Parameters
destIndex uptil which cursor has to be moved. true iff end of vector has been reached while moving cursor. Returns false otherwise.
Postcondition
m0_ivec_varr_cursor_index(cursor) == to.

Definition at line 1250 of file vec.c.

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

◆ m0_ivec_varr_cursor_normalize()

static void m0_ivec_varr_cursor_normalize ( struct m0_ivec_varr_cursor cur)
static

Definition at line 1169 of file vec.c.

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

◆ m0_ivec_varr_cursor_step()

M0_INTERNAL m0_bcount_t m0_ivec_varr_cursor_step ( const struct m0_ivec_varr_cursor cur)

Returns the number of bytes needed to move cursor to next segment in given index vector.

Parameters
curIndex vector to be moved. Number of bytes needed to move the cursor to next segment.

Definition at line 1224 of file vec.c.

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

◆ m0_vec_count()

M0_INTERNAL m0_bcount_t m0_vec_count ( const struct m0_vec vec)

Returns total count of vector

Definition at line 53 of file vec.c.

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

◆ m0_vec_cursor_end()

M0_INTERNAL m0_bcount_t m0_vec_cursor_end ( const struct m0_vec_cursor cur)

Return number of bytes that the cursor have to be moved to reach the end of the vector position.

Precondition
cur->vc_seg < cur->vc_vec->v_nr

Definition at line 132 of file vec.c.

Here is the call graph for this function:

◆ m0_vec_cursor_init()

M0_INTERNAL void m0_vec_cursor_init ( struct m0_vec_cursor cur,
const struct m0_vec vec 
)

Initialise a cursor.

Cursor requires no special finalisation.

Definition at line 92 of file vec.c.

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

◆ m0_vec_cursor_invariant()

static bool m0_vec_cursor_invariant ( const struct m0_vec_cursor cur)
static

Definition at line 69 of file vec.c.

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

◆ m0_vec_cursor_move()

M0_INTERNAL bool m0_vec_cursor_move ( struct m0_vec_cursor cur,
m0_bcount_t  count 
)

Move cursor count bytes further through the vector.

m0_vec_cursor_move(cur, 0) is guaranteed to return true iff cursor is in end of the vector position without modifying cursor in any way.

Returns
true, iff the end of the vector has been reached while moving. The cursor is in end of the vector position in this case.

Definition at line 102 of file vec.c.

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

◆ m0_vec_cursor_normalize()

static void m0_vec_cursor_normalize ( struct m0_vec_cursor cur)
static

Skips over empty segments, restoring cursor invariant.

Definition at line 83 of file vec.c.

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

◆ m0_vec_cursor_step()

M0_INTERNAL m0_bcount_t m0_vec_cursor_step ( const struct m0_vec_cursor cur)

Return number of bytes that the cursor have to be moved to reach the next segment in its vector (or to move into end of the vector position, when the cursor is already at the last segment).

Precondition
cur->vc_seg < cur->vc_vec->v_nr

Definition at line 125 of file vec.c.

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

◆ m0_vec_is_empty()

M0_INTERNAL bool m0_vec_is_empty ( const struct m0_vec vec)

Definition at line 58 of file vec.c.

Here is the caller graph for this function:

◆ M0_XCA_DOMAIN()

struct m0_vec M0_XCA_DOMAIN ( rpc  )

◆ vec_count()

static m0_bcount_t vec_count ( const struct m0_vec vec,
uint32_t  i 
)
static

Definition at line 41 of file vec.c.

Here is the caller graph for this function:

◆ vec_pack()

static uint32_t vec_pack ( uint32_t  nr,
m0_bcount_t cnt,
m0_bindex_t idx 
)
static

Definition at line 454 of file vec.c.

Here is the caller graph for this function:

Variable Documentation

◆ M0_XCA_DOMAIN

struct m0_indexvec_varr M0_XCA_DOMAIN