dm-verity-fec: simplify computation of ileaved

fec_read_bufs() just iterates over a sequence of message blocks with
step size region_blocks.  At each step, 'ileaved' is just the offset (in
bytes) to one of these blocks.  Compute it in the straightforward way,
eliminating fec_interleave().

In more detail, previously the code computed
'ileaved = (n / k) + (n % k) * (region_blocks * block_size)'
where n = rsb * k + i and 0 <= i < k.  Substituting 'n' gives:

    ileaved = ((rsb * k + i) / k) + ((rsb * k + i) % k) * region_blocks * block_size
            = rsb + (i * region_blocks * block_size)

The result is more efficient and easier to understand.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
This commit is contained in:
Eric Biggers 2026-02-05 20:59:33 -08:00 • committed by Mikulas Patocka
commit 5ef22361fa