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: simplify computation of rsb

To compute 'rsb', verity_fec_decode() divides 'offset' by
'v->fec->region_blocks << v->data_dev_block_bits', then subtracts the
quotient times that divisor. That's simply the long way to do a modulo
operation, i.e. a - b * floor(a / b) instead of just a % b. Use
div64_u64_rem() to get the remainder more concisely.

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
8ef45923 41208f37

+3 -3
+3 -3
drivers/md/dm-verity-fec.c
··· 377 377 { 378 378 int r; 379 379 struct dm_verity_fec_io *fio; 380 - u64 offset, res, rsb; 380 + u64 offset, rsb; 381 381 382 382 if (!verity_fec_is_enabled(v)) 383 383 return -EOPNOTSUPP; ··· 405 405 */ 406 406 407 407 offset = block << v->data_dev_block_bits; 408 - res = div64_u64(offset, v->fec->region_blocks << v->data_dev_block_bits); 409 408 410 409 /* 411 410 * The base RS block we can feed to the interleaver to find out all 412 411 * blocks required for decoding. 413 412 */ 414 - rsb = offset - res * (v->fec->region_blocks << v->data_dev_block_bits); 413 + div64_u64_rem(offset, v->fec->region_blocks << v->data_dev_block_bits, 414 + &rsb); 415 415 416 416 /* 417 417 * Locating erasures is slow, so attempt to recover the block without