Motr  M0
cksum.h File Reference
#include "lib/vec.h"
#include "fid/fid.h"
#include "xcode/xcode_attr.h"
#include <openssl/md5.h>
Include dependency graph for cksum.h:

Go to the source code of this file.

Data Structures

struct  m0_pi_hdr
 
struct  m0_md5_pi
 
struct  m0_md5_inc_context_pi
 
struct  m0_generic_pi
 
struct  m0_pi_seed
 

Macros

#define __MOTR_CKSUM_H__
 
#define m0_cksum_print(buf, seg, dbuf, msg)
 
#define M0_CALC_PAD(size, alignment)   ( size%alignment ? (((size/alignment + 1 ) * alignment) - size) : 0)
 

Enumerations

enum  { M0_PI_TYPE_MD5, M0_PI_TYPE_MD5_INC_CONTEXT, M0_PI_TYPE_CRC, M0_PI_TYPE_MAX }
 
enum  m0_pi_calc_flag { M0_PI_NO_FLAG = 0, M0_PI_CALC_UNIT_ZERO = 1 << 0, M0_PI_SKIP_CALC_FINAL = 1 << 1 }
 

Functions

 M0_BASSERT (M0_PI_TYPE_MAX<=8)
 
M0_INTERNAL int m0_calculate_md5_inc_context (struct m0_md5_inc_context_pi *pi, struct m0_pi_seed *seed, struct m0_bufvec *bvec, enum m0_pi_calc_flag flag, unsigned char *curr_context, unsigned char *pi_value_without_seed)
 
M0_INTERNAL uint64_t m0_calculate_cksum_size (struct m0_generic_pi *pi)
 
M0_INTERNAL uint64_t max_cksum_size (void)
 
int m0_client_calculate_pi (struct m0_generic_pi *pi, struct m0_pi_seed *seed, struct m0_bufvec *bvec, enum m0_pi_calc_flag flag, unsigned char *curr_context, unsigned char *pi_value_without_seed)
 
bool m0_calc_verify_cksum_one_unit (struct m0_generic_pi *pi, struct m0_pi_seed *seed, struct m0_bufvec *bvec)
 

Macro Definition Documentation

◆ __MOTR_CKSUM_H__

#define __MOTR_CKSUM_H__

Definition at line 26 of file cksum.h.

◆ M0_CALC_PAD

#define M0_CALC_PAD (   size,
  alignment 
)    ( size%alignment ? (((size/alignment + 1 ) * alignment) - size) : 0)

Definition at line 53 of file cksum.h.

◆ m0_cksum_print

#define m0_cksum_print (   buf,
  seg,
  dbuf,
  msg 
)
Value:
do { \
struct m0_vec *vec = &(buf)->ov_vec; \
char *dst = (char *)(buf)->ov_buf[seg]; \
char *data = (char *)(dbuf)->ov_buf[seg]; \
M0_LOG(M0_DEBUG, msg " count[%d] = %"PRIu64 \
" cksum = %c%c data = %c%c", \
seg, vec->v_count[seg], dst[0], dst[1], data[0],data[1]); \
}while(0)
static struct m0_bufvec dst
Definition: xform.c:61
struct m0_bufvec data
Definition: di.c:40
Definition: vec.h:49
static int void * buf
Definition: dir.c:1019
void ** ov_buf
Definition: vec.h:149
Definition: sock.c:887
#define PRIu64
Definition: types.h:58
static void * vec
Definition: xcode.c:168
static struct m0_be_seg * seg
Definition: btree.c:40

Definition at line 36 of file cksum.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
M0_PI_TYPE_MD5 
M0_PI_TYPE_MD5_INC_CONTEXT 
M0_PI_TYPE_CRC 
M0_PI_TYPE_MAX 

Definition at line 57 of file cksum.h.

◆ m0_pi_calc_flag

Enumerator
M0_PI_NO_FLAG 
M0_PI_CALC_UNIT_ZERO 
M0_PI_SKIP_CALC_FINAL 

Definition at line 65 of file cksum.h.

Function Documentation

◆ M0_BASSERT()

M0_BASSERT ( M0_PI_TYPE_MAX<=  8)

◆ m0_calc_verify_cksum_one_unit()

bool m0_calc_verify_cksum_one_unit ( struct m0_generic_pi pi,
struct m0_pi_seed seed,
struct m0_bufvec bvec 
)

Calculates checksum for data sent and compare it with checksum value sent. If newly calculated checksum on data and checksum sent matches, return true else return false.

Parameters
[IN]pi This ia an already calculated checksum value structure.
[IN]seed This seed is required to calculate checksum
[IN]bvec buffer vector which contains pointers to data on which checksum is to be calculated.

Definition at line 194 of file cksum.c.

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

◆ m0_calculate_cksum_size()

M0_INTERNAL uint64_t m0_calculate_cksum_size ( struct m0_generic_pi pi)

Calculate checksum size

Parameters
pigeneric pointer for checksum data structure

Definition at line 146 of file cksum.c.

◆ m0_calculate_md5_inc_context()

M0_INTERNAL int m0_calculate_md5_inc_context ( struct m0_md5_inc_context_pi pi,
struct m0_pi_seed seed,
struct m0_bufvec bvec,
enum m0_pi_calc_flag  flag,
unsigned char *  curr_context,
unsigned char *  pi_value_without_seed 
)

Calculate checksum/protection info for data/KV

Parameters
pipi struct m0_md5_inc_context_pi This function will calculate the checksum and set pi_value field of struct m0_md5_inc_context_pi.
seedseed value (pis_obj_id+pis_data_unit_offset) required to calculate the checksum. If this pointer is NULL that means either this checksum calculation is meant for KV or user does not want seeding.
m0_bufvec- Set of buffers for which checksum is computed.
flagif flag is M0_PI_CALC_UNIT_ZERO, it means this api is called for first data unit and MD5_Init should be invoked.
[out]curr_contextcontext of data unit N, will be required to calculate checksum for next data unit, N+1. Curre_context is calculated and set in this func.
[out]pi_value_without_seed- Caller may need checksum value without seed and with seed. With seed checksum is set in pi_value of PI type struct. Without seed checksum is set in this field.

Definition at line 30 of file cksum.c.

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

◆ m0_client_calculate_pi()

int m0_client_calculate_pi ( struct m0_generic_pi pi,
struct m0_pi_seed seed,
struct m0_bufvec bvec,
enum m0_pi_calc_flag  flag,
unsigned char *  curr_context,
unsigned char *  pi_value_without_seed 
)

Calculate checksum/protection info for data/KV

Parameters
[IN/OUT]pi Caller will pass Generic pi struct, which will be typecasted to specific PI type struct. API will calculate the checksum and set pi_value of PI type struct. In case of context, caller will send data unit N-1 unit's context via prev_context field in PI type struct. This api will calculate unit N's context and set value in curr_context. IN values - pi_type, pi_size, prev_context OUT values - pi_value, prev_context for first data unit.
[IN]seed seed value (pis_obj_id+pis_data_unit_offset) required to calculate the checksum. If this pointer is NULL that means either this checksum calculation is meant for KV or user does not want seeding. NOTE: seed is always NULL, non-null value sent at the last chunk of motr unit
[IN]m0_bufvec Set of buffers for which checksum is computed. Normally this set of vectors will make one data unit. It can be NULL as well.
[IN]flag If flag is M0_PI_CALC_UNIT_ZERO, it means this api is called for first data unit and init functionality should be invoked such as MD5_Init.
[OUT]curr_context context of data unit N, will be required to calculate checksum for next data unit, N+1. This api will calculate and set value for this field. NOTE: curr_context always have unseeded and non finalised context value and sending this parameter is mandatory.
[OUT]pi_value_without_seed Caller may need checksum value without seed and with seed. With seed checksum is set in pi_value of PI type struct. Without seed checksum is set in this field. Caller has to allocate memory for this filed.

Definition at line 168 of file cksum.c.

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

◆ max_cksum_size()

M0_INTERNAL uint64_t max_cksum_size ( void  )

Return max cksum size possible

Definition at line 162 of file cksum.c.

Here is the caller graph for this function: