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: rename rounds to region_blocks

It's hard to reconcile the value stored in dm_verity_fec::rounds with
its name and documentation. Most likely "rounds" is being used as an
alias for what is more commonly called the interleaving degree or
"number of ways". But the interleaving is done at the byte level,
whereas the units of "rounds" are blocks. So it's not really that.

In practice, the reason the code needs this value is that it expresses
the number of blocks in each "region" of the message data, where each
region contains the bytes from a particular index in the RS codewords.

Rename it to region_blocks to make the code a bit more understandable.

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
41208f37 e75d5546

+9 -9
+8 -8
drivers/md/dm-verity-fec.c
··· 31 31 u32 mod; 32 32 33 33 mod = do_div(offset, v->fec->rs_k); 34 - return offset + mod * (v->fec->rounds << v->data_dev_block_bits); 34 + return offset + mod * (v->fec->region_blocks << v->data_dev_block_bits); 35 35 } 36 36 37 37 /* Loop over each allocated buffer. */ ··· 405 405 */ 406 406 407 407 offset = block << v->data_dev_block_bits; 408 - res = div64_u64(offset, v->fec->rounds << v->data_dev_block_bits); 408 + res = div64_u64(offset, v->fec->region_blocks << v->data_dev_block_bits); 409 409 410 410 /* 411 411 * The base RS block we can feed to the interleaver to find out all 412 412 * blocks required for decoding. 413 413 */ 414 - rsb = offset - res * (v->fec->rounds << v->data_dev_block_bits); 414 + rsb = offset - res * (v->fec->region_blocks << v->data_dev_block_bits); 415 415 416 416 /* 417 417 * Locating erasures is slow, so attempt to recover the block without ··· 659 659 return -EINVAL; 660 660 } 661 661 662 - f->rounds = f->blocks; 663 - if (sector_div(f->rounds, f->rs_k)) 664 - f->rounds++; 662 + f->region_blocks = f->blocks; 663 + if (sector_div(f->region_blocks, f->rs_k)) 664 + f->region_blocks++; 665 665 666 666 /* 667 667 * Due to optional metadata, f->blocks can be larger than 668 668 * data_blocks and hash_blocks combined. 669 669 */ 670 - if (f->blocks < v->data_blocks + hash_blocks || !f->rounds) { 670 + if (f->blocks < v->data_blocks + hash_blocks || !f->region_blocks) { 671 671 ti->error = "Invalid " DM_VERITY_OPT_FEC_BLOCKS; 672 672 return -EINVAL; 673 673 } ··· 693 693 694 694 dm_bufio_set_sector_offset(f->bufio, f->start << (v->data_dev_block_bits - SECTOR_SHIFT)); 695 695 696 - if (dm_bufio_get_device_size(f->bufio) < f->rounds * f->roots) { 696 + if (dm_bufio_get_device_size(f->bufio) < f->region_blocks * f->roots) { 697 697 ti->error = "FEC device is too small"; 698 698 return -E2BIG; 699 699 }
+1 -1
drivers/md/dm-verity-fec.h
··· 32 32 size_t block_size; /* size of data, hash, and parity blocks in bytes */ 33 33 sector_t start; /* parity data start in blocks */ 34 34 sector_t blocks; /* number of blocks covered */ 35 - sector_t rounds; /* number of interleaving rounds */ 35 + sector_t region_blocks; /* blocks per region: ceil(blocks / rs_k) */ 36 36 sector_t hash_blocks; /* blocks covered after v->hash_start */ 37 37 unsigned char roots; /* parity bytes per RS codeword, n-k of RS(n, k) */ 38 38 unsigned char rs_k; /* message bytes per RS codeword, k of RS(n, k) */