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 <[email protected]>
---
 drivers/md/dm-verity-fec.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c
index 3122017569718..a49c43ca07763 100644
--- a/drivers/md/dm-verity-fec.c
+++ b/drivers/md/dm-verity-fec.c
@@ -42,19 +42,10 @@ static inline u8 *fec_buffer_rs_message(struct dm_verity *v,
                                        unsigned int i, unsigned int j)
 {
        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.
  */
 static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_io *io,
@@ -177,11 +168,11 @@ static int fec_read_bufs(struct dm_verity *v, struct 
dm_verity_io *io,
        struct dm_bufio_client *bufio;
        struct dm_verity_fec_io *fio = io->fec_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)
                *neras = 0;
 
@@ -252,17 +243,15 @@ 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);
        }
 
-- 
2.52.0


Reply via email to