Motr  M0
Data integrity using checksum

Data Structures

struct  di_info
 
struct  m0_di_type
 
struct  m0_di_ops
 

Macros

#define CRC_POLY   0x04C11DB7
 
#define CRC_WIDTH   32
 
#define CRC_SLICE_SIZE   8
 
#define CRC_TABLE_SIZE   256
 
#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_FILE
 
#define M0_MD_DI_SET(obj, field)
 
#define M0_MD_DI_CHK(obj, field)
 

Enumerations

enum  m0_di_checksum_len { M0_DI_CRC32_LEN = 1, M0_DI_ELEMENT_SIZE = 64 }
 
enum  m0_di_types {
  M0_DI_NONE, M0_DI_CRC32_4K, M0_DI_CRC32_64K, M0_DI_T10_DIF,
  M0_DI_NR
}
 
enum  { M0_DI_DEFAULT_TYPE }
 

Functions

static uint64_t md_crc32_cksum (void *data, uint64_t len, uint64_t *cksum)
 
static void crc_mktable (void)
 
static uint32_t crc32 (uint32_t crc, unsigned char const *data, m0_bcount_t len)
 
M0_INTERNAL void m0_crc32 (const void *data, uint64_t len, uint64_t *cksum)
 
M0_INTERNAL bool m0_crc32_chk (const void *data, uint64_t len, const uint64_t *cksum)
 
static void md_crc32_cksum_set (void *data, uint64_t len, uint64_t *cksum)
 
static bool md_crc32_cksum_check (void *data, uint64_t len, uint64_t *cksum)
 
static m0_bcount_t current_pos (const struct di_info *info, int i)
 
static uint64_t file_di_crc_mask (const struct m0_file *file)
 
static uint64_t file_di_crc_in_shift (const struct m0_file *file)
 
static uint64_t file_di_crc_out_shift (const struct m0_file *file)
 
static void file_di_crc_sum (const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in_vec, struct m0_bufvec *di_vec)
 
static bool file_di_crc_check (const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in_vec, const struct m0_bufvec *di_vec)
 
static void file_checksum (void(*checksum)(const void *data, m0_bcount_t bsize, uint64_t *csum), const struct m0_bufvec *in_vec, const struct m0_indexvec *io_info, struct di_info *di, struct m0_bufvec *di_vec)
 
static bool file_checksum_check (bool(*checksum)(const void *data, m0_bcount_t bsize, const uint64_t *csum), const struct m0_bufvec *in_vec, const struct m0_indexvec *io_info, struct di_info *di, const struct m0_bufvec *di_vec)
 
static void t10_ref_tag_compute (const struct m0_indexvec *io_info, struct di_info *di, struct m0_bufvec *di_vec)
 
static bool t10_ref_tag_check (const struct m0_indexvec *io_info, struct di_info *di, const struct m0_bufvec *di_vec)
 
static void file_di_info_setup (const struct m0_file *file, const struct m0_indexvec *io_info, struct di_info *di)
 
static void file_di_none_sum (const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in_vec, struct m0_bufvec *di_vec)
 
static bool file_di_none_check (const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in_vec, const struct m0_bufvec *di_vec)
 
static uint64_t file_di_none_mask (const struct m0_file *file)
 
static uint64_t file_di_none_in_shift (const struct m0_file *file)
 
static uint64_t file_di_none_out_shift (const struct m0_file *file)
 
static bool file_di_invariant (const struct m0_bufvec *in_vec, const struct m0_bufvec *di_vec, const struct m0_indexvec *io_info, const struct di_info *di)
 
M0_INTERNAL const struct m0_di_opsm0_di_ops_get (enum m0_di_types di_type)
 
M0_INTERNAL void m0_md_di_set (void *addr, m0_bcount_t nob, uint64_t *cksum_field)
 
M0_INTERNAL bool m0_md_di_chk (void *addr, m0_bcount_t nob, uint64_t *cksum_field)
 
M0_INTERNAL m0_bcount_t m0_di_size_get (const struct m0_file *file, const m0_bcount_t size)
 

Variables

uint32_t crc_table [CRC_TABLE_SIZE]
 
static bool is_table = false
 
static struct m0_di_type file_di_crc
 
static struct m0_di_type file_di_none_type
 
static const struct m0_di_ops di_ops [M0_DI_NR]
 

Detailed Description

Checksum for data blocks is computed based on checksum algorithm selected from configuration. Also checksum length is chosen based on this algorithm.

A di data bufvec, consisting of a single buffer is added as m0_buf in iofop and passed across the network.

Data-integrity type represents a particular combination of data-integrity methods applied to a file.

i.e., data-integrity type prescribes a particular check-summing algorithm with a particular block size, producing output of a particular size, plus, possibly, a particular encryption algorithm, etc.

Data integrity type and operations are initialized in m0_file. Using do_sum(), checksum values are computed for each block of data and using do_chk() checksum values are verified.

For documentation links, please refer to this file : doc/motr-design-doc-list.rst

Macro Definition Documentation

◆ CRC_POLY

#define CRC_POLY   0x04C11DB7

Table-driven implementaion of crc32. CRC table is generated during first crc operation which contains the all possible crc values for the byte of data. These values are used to compute CRC for the all the bytes of data in the block of given length.

Definition at line 40 of file crc.c.

◆ CRC_SLICE_SIZE

#define CRC_SLICE_SIZE   8

Definition at line 42 of file crc.c.

◆ CRC_TABLE_SIZE

#define CRC_TABLE_SIZE   256

Definition at line 43 of file crc.c.

◆ CRC_WIDTH

#define CRC_WIDTH   32

Definition at line 41 of file crc.c.

◆ M0_MD_DI_CHK

#define M0_MD_DI_CHK (   obj,
  field 
)
Value:
({ \
void *__obj = (obj); \
m0_md_di_chk(__obj, sizeof *(obj), &__obj->field); \
})
static struct foo * obj
Definition: tlist.c:302

Definition at line 164 of file di.h.

◆ M0_MD_DI_SET

#define M0_MD_DI_SET (   obj,
  field 
)
Value:
({ \
void *__obj = (obj); \
m0_md_di_set(__obj, sizeof *(obj), &__obj->field); \
})
static struct foo * obj
Definition: tlist.c:302

Definition at line 158 of file di.h.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_FILE

Definition at line 28 of file di.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
M0_DI_DEFAULT_TYPE 

Definition at line 83 of file di.h.

◆ m0_di_checksum_len

Enumerator
M0_DI_CRC32_LEN 
M0_DI_ELEMENT_SIZE 

Definition at line 67 of file di.h.

◆ m0_di_types

Enumerator
M0_DI_NONE 
M0_DI_CRC32_4K 

CRC32 checksum for block size data of 4k.

M0_DI_CRC32_64K 

CRC32 checksum for block size data of 16k.

M0_DI_T10_DIF 

T10 tag for block size data of 4k.

M0_DI_NR 

Definition at line 72 of file di.h.

Function Documentation

◆ crc32()

static uint32_t crc32 ( uint32_t  crc,
unsigned char const *  data,
m0_bcount_t  len 
)
static

Definition at line 66 of file crc.c.

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

◆ crc_mktable()

static void crc_mktable ( void  )
static

Definition at line 48 of file crc.c.

Here is the caller graph for this function:

◆ current_pos()

static m0_bcount_t current_pos ( const struct di_info info,
int  i 
)
static

Definition at line 45 of file di.c.

Here is the caller graph for this function:

◆ file_checksum()

static void file_checksum ( void(*)(const void *data, m0_bcount_t bsize, uint64_t *csum)  checksum,
const struct m0_bufvec in_vec,
const struct m0_indexvec io_info,
struct di_info di,
struct m0_bufvec di_vec 
)
static

Definition at line 227 of file di.c.

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

◆ file_checksum_check()

static bool file_checksum_check ( bool(*)(const void *data, m0_bcount_t bsize, const uint64_t *csum)  checksum,
const struct m0_bufvec in_vec,
const struct m0_indexvec io_info,
struct di_info di,
const struct m0_bufvec di_vec 
)
static

Definition at line 290 of file di.c.

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

◆ file_di_crc_check()

static bool file_di_crc_check ( const struct m0_file file,
const struct m0_indexvec io_info,
const struct m0_bufvec in_vec,
const struct m0_bufvec di_vec 
)
static

Definition at line 255 of file di.c.

Here is the call graph for this function:

◆ file_di_crc_in_shift()

static uint64_t file_di_crc_in_shift ( const struct m0_file file)
static

Definition at line 153 of file di.c.

◆ file_di_crc_mask()

static uint64_t file_di_crc_mask ( const struct m0_file file)
static

Definition at line 148 of file di.c.

Here is the caller graph for this function:

◆ file_di_crc_out_shift()

static uint64_t file_di_crc_out_shift ( const struct m0_file file)
static

Definition at line 158 of file di.c.

Here is the call graph for this function:

◆ file_di_crc_sum()

static void file_di_crc_sum ( const struct m0_file file,
const struct m0_indexvec io_info,
const struct m0_bufvec in_vec,
struct m0_bufvec di_vec 
)
static

Definition at line 163 of file di.c.

Here is the call graph for this function:

◆ file_di_info_setup()

static void file_di_info_setup ( const struct m0_file file,
const struct m0_indexvec io_info,
struct di_info di 
)
static

Definition at line 182 of file di.c.

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

◆ file_di_invariant()

static bool file_di_invariant ( const struct m0_bufvec in_vec,
const struct m0_bufvec di_vec,
const struct m0_indexvec io_info,
const struct di_info di 
)
static

Definition at line 193 of file di.c.

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

◆ file_di_none_check()

static bool file_di_none_check ( const struct m0_file file,
const struct m0_indexvec io_info,
const struct m0_bufvec in_vec,
const struct m0_bufvec di_vec 
)
static

Definition at line 105 of file di.c.

◆ file_di_none_in_shift()

static uint64_t file_di_none_in_shift ( const struct m0_file file)
static

Definition at line 118 of file di.c.

◆ file_di_none_mask()

static uint64_t file_di_none_mask ( const struct m0_file file)
static

Definition at line 113 of file di.c.

◆ file_di_none_out_shift()

static uint64_t file_di_none_out_shift ( const struct m0_file file)
static

Definition at line 123 of file di.c.

◆ file_di_none_sum()

static void file_di_none_sum ( const struct m0_file file,
const struct m0_indexvec io_info,
const struct m0_bufvec in_vec,
struct m0_bufvec di_vec 
)
static

Definition at line 97 of file di.c.

◆ m0_crc32()

M0_INTERNAL void m0_crc32 ( const void *  data,
uint64_t  len,
uint64_t *  cksum 
)

Computes crc32 checksum for data of length "len" and stores it in "cksum".

Parameters
dataA block of data of size "len".
lenLength of data.
cksumChecksum values to be computed are stored in it.

Definition at line 83 of file crc.c.

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

◆ m0_crc32_chk()

M0_INTERNAL bool m0_crc32_chk ( const void *  data,
uint64_t  len,
const uint64_t *  cksum 
)

Compares the crc32 checksum for data of length "len" with checksum values in "cksum".

Parameters
dataA block of data of size "len".
lenLength of data.
cksumChecksum values to be verified are read from it..

Definition at line 93 of file crc.c.

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

◆ m0_di_ops_get()

M0_INTERNAL const struct m0_di_ops * m0_di_ops_get ( enum m0_di_types  di_type)

Returns di ops for a given di_type.

Definition at line 365 of file di.c.

Here is the caller graph for this function:

◆ m0_di_size_get()

M0_INTERNAL m0_bcount_t m0_di_size_get ( const struct m0_file file,
const m0_bcount_t  size 
)

Definition at line 384 of file di.c.

Here is the caller graph for this function:

◆ m0_md_di_chk()

M0_INTERNAL bool m0_md_di_chk ( void *  addr,
m0_bcount_t  nob,
uint64_t *  cksum_field 
)

Compares the checksum value in cksum_field with the computed checksum for this region.

Parameters
cksum_fieldAddress of the checksum field

Definition at line 378 of file di.c.

Here is the call graph for this function:

◆ m0_md_di_set()

M0_INTERNAL void m0_md_di_set ( void *  addr,
m0_bcount_t  nob,
uint64_t *  cksum_field 
)

Computes the checksum for the region excluding checksum field and sets this value in the checksum field.

Parameters
cksum_fieldAddress of the checksum field

Definition at line 372 of file di.c.

Here is the call graph for this function:

◆ md_crc32_cksum()

static uint64_t md_crc32_cksum ( void *  data,
uint64_t  len,
uint64_t *  cksum 
)
static

Definition at line 108 of file crc.c.

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

◆ md_crc32_cksum_check()

static bool md_crc32_cksum_check ( void *  data,
uint64_t  len,
uint64_t *  cksum 
)
static

Definition at line 120 of file crc.c.

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

◆ md_crc32_cksum_set()

static void md_crc32_cksum_set ( void *  data,
uint64_t  len,
uint64_t *  cksum 
)
static

Definition at line 103 of file crc.c.

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

◆ t10_ref_tag_check()

static bool t10_ref_tag_check ( const struct m0_indexvec io_info,
struct di_info di,
const struct m0_bufvec di_vec 
)
static

Definition at line 339 of file di.c.

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

◆ t10_ref_tag_compute()

static void t10_ref_tag_compute ( const struct m0_indexvec io_info,
struct di_info di,
struct m0_bufvec di_vec 
)
static

Definition at line 321 of file di.c.

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

Variable Documentation

◆ crc_table

uint32_t crc_table[CRC_TABLE_SIZE]

Definition at line 45 of file crc.c.

◆ di_ops

const struct m0_di_ops di_ops[M0_DI_NR]
static
Initial value:
= {
[M0_DI_NONE] = {
.do_type = &file_di_none_type,
.do_mask = file_di_none_mask,
.do_in_shift = file_di_none_in_shift,
.do_out_shift = file_di_none_out_shift,
.do_sum = file_di_none_sum,
.do_check = file_di_none_check,
},
.do_type = &file_di_crc,
.do_mask = file_di_crc_mask,
.do_in_shift = file_di_crc_in_shift,
.do_out_shift = file_di_crc_out_shift,
.do_sum = file_di_crc_sum,
.do_check = file_di_crc_check,
},
}
static void file_di_none_sum(const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in_vec, struct m0_bufvec *di_vec)
Definition: di.c:97
static struct m0_di_type file_di_crc
Definition: di.c:89
static bool file_di_crc_check(const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in_vec, const struct m0_bufvec *di_vec)
Definition: di.c:255
static void file_di_crc_sum(const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in_vec, struct m0_bufvec *di_vec)
Definition: di.c:163
static bool file_di_none_check(const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in_vec, const struct m0_bufvec *di_vec)
Definition: di.c:105
static uint64_t file_di_none_mask(const struct m0_file *file)
Definition: di.c:113
static uint64_t file_di_crc_in_shift(const struct m0_file *file)
Definition: di.c:153
static uint64_t file_di_none_in_shift(const struct m0_file *file)
Definition: di.c:118
static uint64_t file_di_crc_out_shift(const struct m0_file *file)
Definition: di.c:158
static uint64_t file_di_crc_mask(const struct m0_file *file)
Definition: di.c:148
Definition: di.h:73
static uint64_t file_di_none_out_shift(const struct m0_file *file)
Definition: di.c:123
static struct m0_di_type file_di_none_type
Definition: di.c:93

Definition at line 128 of file di.c.

◆ file_di_crc

struct m0_di_type file_di_crc
static
Initial value:
= {
.dt_name = "crc32-4k+t10-ref-tag",
}

Definition at line 89 of file di.c.

◆ file_di_none_type

struct m0_di_type file_di_none_type
static
Initial value:
= {
.dt_name = "di-none",
}

Definition at line 93 of file di.c.

◆ is_table

bool is_table = false
static

Definition at line 46 of file crc.c.