Motr  M0
utils.c File Reference
#include "motr/client.h"
#include "motr/pg.h"
#include "motr/io.h"
#include "lib/trace.h"
#include "lib/finject.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Functions

M0_INTERNAL bool addr_is_network_aligned (void *addr)
 
M0_INTERNAL uint64_t obj_buffer_size (const struct m0_obj *obj)
 
M0_INTERNAL uint64_t m0__page_size (const struct m0_op_io *ioo)
 
M0_INTERNAL uint64_t page_nr (m0_bcount_t size, struct m0_obj *obj)
 
M0_INTERNAL uint32_t layout_n (struct m0_pdclust_layout *play)
 
M0_INTERNAL uint32_t layout_k (struct m0_pdclust_layout *play)
 
M0_INTERNAL uint64_t page_id (m0_bindex_t offset, struct m0_obj *obj)
 
M0_INTERNAL uint64_t layout_unit_size (struct m0_pdclust_layout *play)
 
M0_INTERNAL uint32_t rows_nr (struct m0_pdclust_layout *play, struct m0_obj *obj)
 
M0_INTERNAL uint64_t data_size (struct m0_pdclust_layout *play)
 
M0_INTERNAL struct m0_pdclust_instancepdlayout_instance (struct m0_layout_instance *li)
 
M0_INTERNAL struct m0_pdclust_layoutpdlayout_get (const struct m0_op_io *ioo)
 
M0_INTERNAL struct m0_layout_instancelayout_instance (const struct m0_op_io *ioo)
 
M0_INTERNAL struct m0_parity_mathparity_math (struct m0_op_io *ioo)
 
M0_INTERNAL uint64_t target_offset (uint64_t frame, struct m0_pdclust_layout *play, m0_bindex_t gob_offset)
 
M0_INTERNAL uint64_t group_id (m0_bindex_t index, m0_bcount_t dtsize)
 
M0_INTERNAL m0_bcount_t seg_endpos (const struct m0_indexvec *ivec, uint32_t i)
 
M0_INTERNAL uint64_t indexvec_page_nr (const struct m0_vec *vec, struct m0_obj *obj)
 
M0_INTERNAL uint64_t iomap_page_nr (const struct pargrp_iomap *map)
 
M0_INTERNAL uint64_t parity_units_page_nr (struct m0_pdclust_layout *play, struct m0_obj *obj)
 
M0_INTERNAL uint64_t round_down (uint64_t val, uint64_t size)
 
M0_INTERNAL uint64_t round_up (uint64_t val, uint64_t size)
 
M0_INTERNAL uint32_t io_desc_size (struct m0_net_domain *ndom)
 
M0_INTERNAL uint32_t io_seg_size (void)
 
M0_INTERNAL void page_pos_get (struct pargrp_iomap *map, m0_bindex_t index, m0_bindex_t grp_off, uint32_t *row, uint32_t *col)
 
M0_INTERNAL m0_bindex_t data_page_offset_get (struct pargrp_iomap *map, uint32_t row, uint32_t col)
 
M0_INTERNAL uint32_t ioreq_sm_state (const struct m0_op_io *ioo)
 
M0_INTERNAL uint64_t tolerance_of_level (struct m0_op_io *ioo, uint64_t lv)
 
M0_INTERNAL bool m0__is_update_op (struct m0_op *op)
 
M0_INTERNAL bool m0__is_read_op (struct m0_op *op)
 
M0_INTERNAL struct m0_obj_attrm0_io_attr (struct m0_op_io *ioo)
 

Function Documentation

◆ addr_is_network_aligned()

M0_INTERNAL bool addr_is_network_aligned ( void *  addr)

Determines whether the provided pointer is aligned for use directly by the network code.

Parameters
addrThe address to check.
Returns
true/false whether the address is aligned.

Definition at line 29 of file utils.c.

Here is the caller graph for this function:

◆ data_page_offset_get()

M0_INTERNAL m0_bindex_t data_page_offset_get ( struct pargrp_iomap map,
uint32_t  row,
uint32_t  col 
)

Definition at line 246 of file utils.c.

Here is the call graph for this function:

◆ data_size()

M0_INTERNAL uint64_t data_size ( struct m0_pdclust_layout play)

Determines the total size of data units in a parity group.

Definition at line 95 of file utils.c.

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

◆ group_id()

M0_INTERNAL uint64_t group_id ( m0_bindex_t  index,
m0_bcount_t  dtsize 
)

Calculates the group index, given a data index and the block size.

Parameters
indexThe data index.
dtsizeThe block size for this data.
Returns
the group index of the data index.

Definition at line 139 of file utils.c.

◆ indexvec_page_nr()

M0_INTERNAL uint64_t indexvec_page_nr ( const struct m0_vec vec,
struct m0_obj obj 
)

Counts the/ number of pages in a vector.

Parameters
vecThe vector to inspect.
objThe object this corresponds with, used to find the block shift.
Returns
The number of pages.

Definition at line 152 of file utils.c.

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

◆ io_desc_size()

M0_INTERNAL uint32_t io_desc_size ( struct m0_net_domain ndom)

Calculates additional space for metadata in an io fop, use when adding rpc bulk buffer and data buffers. This is heavily based on m0t1fs/linux_kernel/file.cio_desc_size

Parameters
ndomThe network domain the request will be sent on/to/through.
Returns
The additional space requirement.

Definition at line 205 of file utils.c.

Here is the call graph for this function:

◆ io_seg_size()

M0_INTERNAL uint32_t io_seg_size ( void  )

How much space is required for per-segment on-wire metadata. This is heavily based on m0t1fs/linux_kernel/file.cio_seg_size

Returns
The number of bytes for per-segment on-wire metadata.

Definition at line 218 of file utils.c.

◆ iomap_page_nr()

M0_INTERNAL uint64_t iomap_page_nr ( const struct pargrp_iomap map)

Retrieves the number of pages in the provided map.

Parameters
mapThe map to inspect.
Returns
The number of pages.

Definition at line 161 of file utils.c.

Here is the call graph for this function:

◆ ioreq_sm_state()

M0_INTERNAL uint32_t ioreq_sm_state ( const struct m0_op_io ioo)

Returns the state-machine:state of the provided io operation. This is heavily based on m0t1fs/linux_kernel/file.cioreq_sm_state

Parameters
iooThe IO Operation.
Returns
the io sm state.

Definition at line 268 of file utils.c.

◆ layout_instance()

M0_INTERNAL struct m0_layout_instance* layout_instance ( const struct m0_op_io ioo)

Retrieves the stashed layout instance from the provided IO operation.

Parameters
iooThe IO operation.
Returns
The stashed layout instance.

Definition at line 117 of file utils.c.

Here is the caller graph for this function:

◆ layout_k()

M0_INTERNAL uint32_t layout_k ( struct m0_pdclust_layout play)

Retrieves the K (number of spare/parity servers), parameter from a parity layout.

Parameters
playThe parity layout.
Returns
K

Definition at line 64 of file utils.c.

Here is the caller graph for this function:

◆ layout_n()

M0_INTERNAL uint32_t layout_n ( struct m0_pdclust_layout play)

Retrieves the N (number of data servers), parameter from a parity layout.

Parameters
playThe parity layout.
Returns
N

Definition at line 57 of file utils.c.

Here is the caller graph for this function:

◆ layout_unit_size()

M0_INTERNAL uint64_t layout_unit_size ( struct m0_pdclust_layout play)

Gets the unit size of the parity calculations, from a parity layout.

Parameters
playThe parity layout.
Returns
The unit size.

Definition at line 80 of file utils.c.

Here is the caller graph for this function:

◆ m0__is_read_op()

M0_INTERNAL bool m0__is_read_op ( struct m0_op op)

Definition at line 296 of file utils.c.

Here is the caller graph for this function:

◆ m0__is_update_op()

M0_INTERNAL bool m0__is_update_op ( struct m0_op op)

Definition at line 290 of file utils.c.

Here is the caller graph for this function:

◆ m0__page_size()

M0_INTERNAL uint64_t m0__page_size ( const struct m0_op_io ioo)

Determines the page size of the object to provided operation is on.

Parameters
iooThe operation on an object.
Returns
The objects page size.

Definition at line 41 of file utils.c.

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

◆ m0_io_attr()

M0_INTERNAL struct m0_obj_attr* m0_io_attr ( struct m0_op_io ioo)

Definition at line 302 of file utils.c.

Here is the caller graph for this function:

◆ obj_buffer_size()

M0_INTERNAL uint64_t obj_buffer_size ( const struct m0_obj obj)

Determines the IO buffer size of an object.

Parameters
objThe object.
Returns
The objects buffer size.

Definition at line 34 of file utils.c.

Here is the caller graph for this function:

◆ page_id()

M0_INTERNAL uint64_t page_id ( m0_bindex_t  offset,
struct m0_obj obj 
)

TODO: this code is the same as page_nr -> combine them?

Definition at line 72 of file utils.c.

Here is the caller graph for this function:

◆ page_nr()

M0_INTERNAL uint64_t page_nr ( m0_bcount_t  size,
struct m0_obj obj 
)

Determines the number of object:blocks that are needed to hold the specified amount of data.

Parameters
sizeThe size of the larger buffer.
objThe object that will hold this data.
Returns
the number of blocks required.TODO: rename this block_count ?

Definition at line 49 of file utils.c.

Here is the caller graph for this function:

◆ page_pos_get()

M0_INTERNAL void page_pos_get ( struct pargrp_iomap map,
m0_bindex_t  index,
m0_bindex_t  grp_off,
uint32_t *  row,
uint32_t *  col 
)

TODO: obj can be retrieved from map->pi_ioo

Definition at line 224 of file utils.c.

Here is the call graph for this function:

◆ parity_math()

M0_INTERNAL struct m0_parity_math* parity_math ( struct m0_op_io ioo)

Retrieves the math representation of parity

Parameters
iooThe IO operation
Returns
The parity math representation.

Definition at line 124 of file utils.c.

Here is the call graph for this function:

◆ parity_units_page_nr()

M0_INTERNAL uint64_t parity_units_page_nr ( struct m0_pdclust_layout play,
struct m0_obj obj 
)

Calculates the number of parity pages required for a given layout.

Parameters
playThe parity layout.
objThe object this corresponds with, used to find the block shift.
Returns
The number of parity pages.

Definition at line 168 of file utils.c.

Here is the call graph for this function:

◆ pdlayout_get()

M0_INTERNAL struct m0_pdclust_layout* pdlayout_get ( const struct m0_op_io ioo)

Gets the parity layout from the provided IO operation. This is heavily based on m0t1fs/linux_kernel/file.cpdlayout_get

Parameters
iooThe IO Operation.
Returns
The parity layout.

Definition at line 111 of file utils.c.

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

◆ pdlayout_instance()

M0_INTERNAL struct m0_pdclust_instance* pdlayout_instance ( struct m0_layout_instance li)

Retrieves a parity-declustered instance from the provided layout instance.

Parameters
lithe layout instance.
Returns
The pdclust instance.

Definition at line 103 of file utils.c.

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

◆ round_down()

M0_INTERNAL uint64_t round_down ( uint64_t  val,
uint64_t  size 
)

Rounds val down to the nearest multiple of size. This is heavily based on m0t1fs/linux_kernel/file.cround_down

Parameters
valThe value to round.
sizeThe result should be a multiple of this size.
Returns
The rounded version of val.

Definition at line 178 of file utils.c.

Here is the call graph for this function:

◆ round_up()

M0_INTERNAL uint64_t round_up ( uint64_t  val,
uint64_t  size 
)

Rounds val up to the nearest multiple of size. This is heavily based on m0t1fs/linux_kernel/file.cround_up

Parameters
valThe value to round.
sizeThe result should be a multiple of this size.
Returns
The rounded version of val.

Definition at line 192 of file utils.c.

Here is the call graph for this function:

◆ rows_nr()

M0_INTERNAL uint32_t rows_nr ( struct m0_pdclust_layout play,
struct m0_obj obj 
)

Determines the size of data/parity unit in pages. This is essentially the rows number in the pargrp_iomap::pi_databufs[row][col] 2-dimentional array, hence the name.

Parameters
playThe Parity layout.
objThe object.
Returns
The number of pages.

Definition at line 87 of file utils.c.

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

◆ seg_endpos()

M0_INTERNAL m0_bcount_t seg_endpos ( const struct m0_indexvec ivec,
uint32_t  i 
)

Calculates the offset of the last byte in the i'th extent.

Parameters
ivecThe index of extents.
iWhich extent to inspect.
Returns
The offset of the last byte.

Definition at line 145 of file utils.c.

◆ target_offset()

M0_INTERNAL uint64_t target_offset ( uint64_t  frame,
struct m0_pdclust_layout play,
m0_bindex_t  gob_offset 
)

Calculates the offset in the target object based on the global offset.

Parameters
frameFrame number of target object.
playThe Parity layout for the global object
gob_offsetOffset in global object.
Returns
The target:object offset.

Definition at line 129 of file utils.c.

Here is the call graph for this function:

◆ tolerance_of_level()

M0_INTERNAL uint64_t tolerance_of_level ( struct m0_op_io ioo,
uint64_t  lv 
)
Todo:
This code is not required once MOTR-899 lands into dev. Tolerance for the given level.

Definition at line 275 of file utils.c.

Here is the call graph for this function: