Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dm-verity-fec: use standard names for Reed-Solomon parameters

"RS(n, k)" is by far the most common and standard notation for
describing Reed-Solomon codes. Each RS codeword consists of 'n'
symbols, divided into 'k' message symbols and 'n - k' parity symbols.
'n - k' is also the number of roots of the generator polynomial.

dm-verity uses "RS(M, N)" instead. I haven't been able to find any
other source that uses this convention. This quirk makes the code
harder to understand than necessary, especially due to dm-verity's 'N'
meaning something different from the standard 'n'.

Therefore, update dm-verity-fec.c and dm-verity-fec.h to use the
standard parameter names. No functional changes.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

authored by

Eric Biggers and committed by
Mikulas Patocka
f34ebde1 82fbd6a3

+19 -19
+15 -15
drivers/md/dm-verity-fec.c
··· 29 29 { 30 30 u32 mod; 31 31 32 - mod = do_div(offset, v->fec->rsn); 32 + mod = do_div(offset, v->fec->rs_k); 33 33 return offset + mod * (v->fec->rounds << v->data_dev_block_bits); 34 34 } 35 35 ··· 50 50 struct dm_verity_fec_io *fio, 51 51 unsigned int i, unsigned int j) 52 52 { 53 - return &fio->bufs[i][j * v->fec->rsn]; 53 + return &fio->bufs[i][j * v->fec->rs_k]; 54 54 } 55 55 56 56 /* ··· 129 129 } 130 130 131 131 /* Decode an RS block using Reed-Solomon */ 132 - res = decode_rs8(fio->rs, block, par_buf, v->fec->rsn, 132 + res = decode_rs8(fio->rs, block, par_buf, v->fec->rs_k, 133 133 NULL, neras, fio->erasures, 0, NULL); 134 134 if (res < 0) { 135 135 r = res; ··· 197 197 return -EINVAL; 198 198 199 199 /* 200 - * read each of the rsn data blocks that are part of the RS block, and 200 + * read each of the rs_k data blocks that are part of the RS block, and 201 201 * interleave contents to available bufs 202 202 */ 203 - for (i = 0; i < v->fec->rsn; i++) { 204 - ileaved = fec_interleave(v, rsb * v->fec->rsn + i); 203 + for (i = 0; i < v->fec->rs_k; i++) { 204 + ileaved = fec_interleave(v, rsb * v->fec->rs_k + i); 205 205 206 206 /* 207 207 * target is the data block we want to correct, target_index is 208 - * the index of this block within the rsn RS blocks 208 + * the index of this block within the rs_k RS blocks 209 209 */ 210 210 if (ileaved == target) 211 211 target_index = i; ··· 322 322 unsigned int n; 323 323 324 324 fec_for_each_buffer(fio, n) 325 - memset(fio->bufs[n], 0, v->fec->rsn << DM_VERITY_FEC_BUF_RS_BITS); 325 + memset(fio->bufs[n], 0, v->fec->rs_k << DM_VERITY_FEC_BUF_RS_BITS); 326 326 327 327 memset(fio->erasures, 0, sizeof(fio->erasures)); 328 328 } ··· 394 394 block = block - v->hash_start + v->data_blocks; 395 395 396 396 /* 397 - * For RS(M, N), the continuous FEC data is divided into blocks of N 398 - * bytes. Since block size may not be divisible by N, the last block 397 + * For RS(n, k), the continuous FEC data is divided into blocks of k 398 + * bytes. Since block size may not be divisible by k, the last block 399 399 * is zero padded when decoding. 400 400 * 401 - * Each byte of the block is covered by a different RS(M, N) code, 402 - * and each code is interleaved over N blocks to make it less likely 401 + * Each byte of the block is covered by a different RS(n, k) code, 402 + * and each code is interleaved over k blocks to make it less likely 403 403 * that bursty corruption will leave us in unrecoverable state. 404 404 */ 405 405 ··· 650 650 ti->error = "Missing " DM_VERITY_OPT_FEC_ROOTS; 651 651 return -EINVAL; 652 652 } 653 - f->rsn = DM_VERITY_FEC_RSM - f->roots; 653 + f->rs_k = DM_VERITY_FEC_RS_N - f->roots; 654 654 655 655 if (!f->blocks) { 656 656 ti->error = "Missing " DM_VERITY_OPT_FEC_BLOCKS; ··· 658 658 } 659 659 660 660 f->rounds = f->blocks; 661 - if (sector_div(f->rounds, f->rsn)) 661 + if (sector_div(f->rounds, f->rs_k)) 662 662 f->rounds++; 663 663 664 664 /* ··· 730 730 } 731 731 732 732 f->cache = kmem_cache_create("dm_verity_fec_buffers", 733 - f->rsn << DM_VERITY_FEC_BUF_RS_BITS, 733 + f->rs_k << DM_VERITY_FEC_BUF_RS_BITS, 734 734 0, 0, NULL); 735 735 if (!f->cache) { 736 736 ti->error = "Cannot create FEC buffer cache";
+4 -4
drivers/md/dm-verity-fec.h
··· 11 11 #include "dm-verity.h" 12 12 #include <linux/rslib.h> 13 13 14 - /* Reed-Solomon(M, N) parameters */ 15 - #define DM_VERITY_FEC_RSM 255 14 + /* Reed-Solomon(n, k) parameters */ 15 + #define DM_VERITY_FEC_RS_N 255 16 16 #define DM_VERITY_FEC_MIN_ROOTS 2 /* RS(255, 253): ~0.8% space overhead */ 17 17 #define DM_VERITY_FEC_MAX_ROOTS 24 /* RS(255, 231): ~10% space overhead */ 18 18 ··· 34 34 sector_t blocks; /* number of blocks covered */ 35 35 sector_t rounds; /* number of interleaving rounds */ 36 36 sector_t hash_blocks; /* blocks covered after v->hash_start */ 37 - unsigned char roots; /* number of parity bytes, M-N of RS(M, N) */ 38 - unsigned char rsn; /* N of RS(M, N) */ 37 + unsigned char roots; /* parity bytes per RS codeword, n-k of RS(n, k) */ 38 + unsigned char rs_k; /* message bytes per RS codeword, k of RS(n, k) */ 39 39 mempool_t fio_pool; /* mempool for dm_verity_fec_io */ 40 40 mempool_t rs_pool; /* mempool for fio->rs */ 41 41 mempool_t prealloc_pool; /* mempool for preallocated buffers */