Motr  M0
parity_math.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2021 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #pragma once
23 
24 #ifndef __MOTR_SNS_PARITY_MATH_H__
25 #define __MOTR_SNS_PARITY_MATH_H__
26 
27 #include "lib/vec.h"
28 #include "lib/bitmap.h"
29 #include "lib/tlist.h"
30 #include "matvec.h"
31 #include "ls_solve.h"
32 
53 };
54 
58 };
59 
63 };
64 
68 };
77  /* Index of a block within parity group. */
78  uint32_t sib_idx;
79  /* Data from a block is submitted to incremental-recovery-module using
80  * struct m0_bufvec. sib_addr holds address for the same.
81  */
83  /* Whenever a block fails, sib_bitmap holds block indices of
84  * blocks required for its recovery.
85  */
87  /* Indicates whether a block is available, failed or restored. */
89 };
90 
95  /* Pointer to sets of arrays of input coefficients used
96  * to encode or decode data.*/
97  uint8_t *rs_encode_matrix;
98  /* Pointer to concatenated output tables for encode.
99  * Must be of size MIN_TABLE_LEN * data_count * parity_count
100  */
101  uint8_t *rs_encode_tbls;
102  /* Pointer to concatenated output tables for decode.
103  * Must be of size MIN_TABLE_LEN * data_count * parity_count
104  */
105  uint8_t *rs_decode_tbls;
106  /* Number of failed blocks. */
107  uint32_t rs_failed_nr;
108  /* Array holding indices of all failed blocks. */
109  uint8_t *rs_failed_idx;
110  /* Array holding indices of all alive blocks. */
111  uint8_t *rs_alive_idx;
112  /* Array of buffer pointers to be used as source for encoding or
113  * recovery. */
114  uint8_t **rs_bufs_in;
115  /* Array of buffer pointers to be used as destination for encoding or
116  * recovery. */
117  uint8_t **rs_bufs_out;
118 };
119 
126 
127  uint32_t pmi_data_count;
130 };
131 
132 /* Holds information essential for incremental recovery. */
133 struct m0_sns_ir {
134  uint32_t si_data_nr;
135  uint32_t si_parity_nr;
136  uint32_t si_alive_nr;
137  /* Number of blocks from a parity group that are available locally
138  * on a node. */
139  uint32_t si_local_nr;
140  /* Array holding all blocks */
143 };
144 
151 M0_INTERNAL int m0_parity_math_init(struct m0_parity_math *math,
152  uint32_t data_count, uint32_t parity_count);
153 
158 M0_INTERNAL void m0_parity_math_fini(struct m0_parity_math *math);
159 
167 M0_INTERNAL void m0_parity_math_calculate(struct m0_parity_math *math,
168  struct m0_buf *data,
169  struct m0_buf *parity);
170 
181 M0_INTERNAL int m0_parity_math_diff(struct m0_parity_math *math,
182  struct m0_buf *old_ver,
183  struct m0_buf *new_ver,
184  struct m0_buf *parity, uint32_t index);
185 
195 M0_INTERNAL void m0_parity_math_refine(struct m0_parity_math *math,
196  struct m0_buf *data,
197  struct m0_buf *parity,
198  uint32_t data_ind_changed);
199 
215 M0_INTERNAL int m0_parity_math_recover(struct m0_parity_math *math,
216  struct m0_buf *data,
217  struct m0_buf *parity,
218  struct m0_buf *fails,
219  enum m0_parity_linsys_algo algo);
220 
230 M0_INTERNAL void m0_parity_math_fail_index_recover(struct m0_parity_math *math,
231  struct m0_buf *data,
232  struct m0_buf *parity,
233  const uint32_t
234  failure_index);
235 
243 M0_INTERNAL void m0_parity_math_buffer_xor(struct m0_buf *dest,
244  const struct m0_buf *src);
245 
479 M0_INTERNAL int m0_sns_ir_failure_register(struct m0_bufvec *recov_addr,
480  uint32_t failed_index,
481  struct m0_sns_ir *ir);
482 
493 M0_INTERNAL int m0_sns_ir_init(const struct m0_parity_math *math,
494  uint32_t local_nr, struct m0_sns_ir *ir);
502 M0_INTERNAL int m0_sns_ir_mat_compute(struct m0_sns_ir *ir);
503 
521 M0_INTERNAL int m0_sns_ir_recover(struct m0_sns_ir *ir,
522  struct m0_bufvec *bufvec,
523  const struct m0_bitmap *bitmap,
524  uint32_t failed_index,
525  enum m0_sns_ir_block_type block_type);
533 //M0_INTERNAL void m0_sns_ir_local_xform(struct m0_sns_ir *ir);
534 M0_INTERNAL void m0_sns_ir_fini(struct m0_sns_ir *ir);
539 /* __MOTR_SNS_PARITY_MATH_H__ */
540 #endif
541 
542 /*
543  * Local variables:
544  * c-indentation-style: "K&R"
545  * c-basic-offset: 8
546  * tab-width: 8
547  * fill-column: 80
548  * scroll-step: 1
549  * End:
550  */
enum m0_sns_ir_block_status sib_status
Definition: parity_math.h:88
struct m0_reed_solomon pmi_rs
Definition: parity_math.h:129
M0_INTERNAL void m0_parity_math_fini(struct m0_parity_math *math)
Definition: parity_math.c:325
uint8_t ** rs_bufs_in
Definition: parity_math.h:114
uint32_t sib_idx
Definition: parity_math.h:78
uint32_t pmi_data_count
Definition: parity_math.h:127
enum m0_parity_cal_algo pmi_parity_algo
Definition: parity_math.h:125
M0_INTERNAL void m0_parity_math_buffer_xor(struct m0_buf *dest, const struct m0_buf *src)
Definition: parity_math.c:415
uint32_t si_alive_nr
Definition: parity_math.h:136
struct m0_bufvec data
Definition: di.c:40
uint8_t * rs_encode_matrix
Definition: parity_math.h:97
struct m0_bitmap sib_bitmap
Definition: parity_math.h:86
m0_parity_cal_algo
Definition: parity_math.h:49
M0_INTERNAL int m0_parity_math_recover(struct m0_parity_math *math, struct m0_buf *data, struct m0_buf *parity, struct m0_buf *fails, enum m0_parity_linsys_algo algo)
Definition: parity_math.c:383
M0_INTERNAL void m0_sns_ir_fini(struct m0_sns_ir *ir)
Definition: parity_math.c:488
M0_INTERNAL int m0_parity_math_diff(struct m0_parity_math *math, struct m0_buf *old_ver, struct m0_buf *new_ver, struct m0_buf *parity, uint32_t index)
Definition: parity_math.c:371
struct m0_sns_ir_block * si_blocks
Definition: parity_math.h:141
M0_INTERNAL int m0_sns_ir_failure_register(struct m0_bufvec *recov_addr, uint32_t failed_index, struct m0_sns_ir *ir)
Definition: parity_math.c:453
M0_INTERNAL int m0_sns_ir_init(const struct m0_parity_math *math, uint32_t local_nr, struct m0_sns_ir *ir)
Definition: parity_math.c:425
M0_INTERNAL void m0_parity_math_calculate(struct m0_parity_math *math, struct m0_buf *data, struct m0_buf *parity)
Definition: parity_math.c:362
Definition: buf.h:37
M0_INTERNAL void m0_parity_math_refine(struct m0_parity_math *math, struct m0_buf *data, struct m0_buf *parity, uint32_t data_ind_changed)
Definition: parity_math.c:406
struct m0_bufvec * sib_addr
Definition: parity_math.h:82
M0_INTERNAL int m0_sns_ir_recover(struct m0_sns_ir *ir, struct m0_bufvec *bufvec, const struct m0_bitmap *bitmap, uint32_t failed_index, enum m0_sns_ir_block_type block_type)
Definition: parity_math.c:503
M0_INTERNAL int m0_sns_ir_mat_compute(struct m0_sns_ir *ir)
Definition: parity_math.c:482
M0_INTERNAL int m0_parity_math_init(struct m0_parity_math *math, uint32_t data_count, uint32_t parity_count)
Definition: parity_math.c:333
struct m0_reed_solomon si_rs
Definition: parity_math.h:142
uint8_t * rs_failed_idx
Definition: parity_math.h:109
uint8_t * rs_decode_tbls
Definition: parity_math.h:105
uint8_t ** rs_bufs_out
Definition: parity_math.h:117
uint32_t si_data_nr
Definition: parity_math.h:134
m0_sns_ir_block_status
Definition: parity_math.h:55
uint32_t si_local_nr
Definition: parity_math.h:139
uint8_t * rs_alive_idx
Definition: parity_math.h:111
uint32_t rs_failed_nr
Definition: parity_math.h:107
m0_sns_ir_block_type
Definition: parity_math.h:60
uint8_t * rs_encode_tbls
Definition: parity_math.h:101
M0_INTERNAL void m0_parity_math_fail_index_recover(struct m0_parity_math *math, struct m0_buf *data, struct m0_buf *parity, const uint32_t failure_index)
Definition: parity_math.c:396
struct m0_pdclust_src_addr src
Definition: fd.c:108
uint32_t pmi_parity_count
Definition: parity_math.h:128
uint32_t si_parity_nr
Definition: parity_math.h:135
static uint8_t parity[DATA_UNIT_COUNT_MAX][UNIT_BUFF_SIZE_MAX]
Definition: vec.h:145
m0_parity_linsys_algo
Definition: parity_math.h:65