]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dm-verity-fec: simplify deinterleaving
authorEric Biggers <ebiggers@kernel.org>
Fri, 6 Feb 2026 04:59:34 +0000 (20:59 -0800)
committerMikulas Patocka <mpatocka@redhat.com>
Mon, 9 Mar 2026 14:13:02 +0000 (15:13 +0100)
Since fec_read_bufs() deinterleaves the bytes from 'bbuf' sequentially
starting from 'block_offset', it can just do simple increments instead
of the more complex fec_buffer_rs_index() computation.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-verity-fec.c

index baf988c297618c7ea5add13ec3ebe277c56331b9..4aee948dde5d7a3fe13cdc5ff37c1a91eeea53e8 100644 (file)
@@ -44,15 +44,6 @@ static inline u8 *fec_buffer_rs_message(struct dm_verity *v,
        return &fio->bufs[i][j * v->fec->rs_k];
 }
 
-/*
- * Return the index of the current RS message when called inside
- * fec_for_each_buffer_rs_message.
- */
-static inline unsigned int fec_buffer_rs_index(unsigned int i, unsigned int j)
-{
-       return (i << DM_VERITY_FEC_BUF_RS_BITS) + j;
-}
-
 /*
  * Decode all RS codewords whose message bytes were loaded into fio->bufs.  Copy
  * the corrected bytes into fio->output starting from block_offset.
@@ -179,7 +170,7 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io,
        u64 block, ileaved;
        u8 *bbuf;
        u8 want_digest[HASH_MAX_DIGESTSIZE];
-       unsigned int n, k;
+       unsigned int n, src_pos;
        struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
 
        if (neras)
@@ -254,13 +245,11 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io,
                 * deinterleave and copy the bytes that fit into bufs,
                 * starting from block_offset
                 */
+               src_pos = block_offset;
                fec_for_each_buffer_rs_message(fio, n, j) {
-                       k = fec_buffer_rs_index(n, j) + block_offset;
-
-                       if (k >= v->fec->block_size)
+                       if (src_pos >= v->fec->block_size)
                                goto done;
-
-                       fec_buffer_rs_message(v, fio, n, j)[i] = bbuf[k];
+                       fec_buffer_rs_message(v, fio, n, j)[i] = bbuf[src_pos++];
                }
 done:
                dm_bufio_release(buf);