]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
dm-verity-fec: simplify computation of ileaved
authorEric Biggers <ebiggers@kernel.org>
Fri, 6 Feb 2026 04:59:33 +0000 (20:59 -0800)
committerMikulas Patocka <mpatocka@redhat.com>
Mon, 9 Mar 2026 14:12:53 +0000 (15:12 +0100)
commit5ef22361fa98a44409f11a10cb7d08b5cbf6d57c
tree34f54298372a6c1e5366854f33e83d902043ce38
parent8ef45923fdcb7ec44e3a965bcbf41723e20814e4
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>
drivers/md/dm-verity-fec.c