]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dm-verity-fec: rename rounds to region_blocks
authorEric Biggers <ebiggers@kernel.org>
Fri, 6 Feb 2026 04:59:31 +0000 (20:59 -0800)
committerMikulas Patocka <mpatocka@redhat.com>
Mon, 9 Mar 2026 14:12:38 +0000 (15:12 +0100)
It's hard to reconcile the value stored in dm_verity_fec::rounds with
its name and documentation.  Most likely "rounds" is being used as an
alias for what is more commonly called the interleaving degree or
"number of ways".  But the interleaving is done at the byte level,
whereas the units of "rounds" are blocks.  So it's not really that.

In practice, the reason the code needs this value is that it expresses
the number of blocks in each "region" of the message data, where each
region contains the bytes from a particular index in the RS codewords.

Rename it to region_blocks to make the code a bit more understandable.

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

index 1251d45f6f852176a596839d7f3557f9fe82d4a0..d132fd5dc7b43b39b96b87d33d3d8cb796942cc6 100644 (file)
@@ -31,7 +31,7 @@ static inline u64 fec_interleave(struct dm_verity *v, u64 offset)
        u32 mod;
 
        mod = do_div(offset, v->fec->rs_k);
-       return offset + mod * (v->fec->rounds << v->data_dev_block_bits);
+       return offset + mod * (v->fec->region_blocks << v->data_dev_block_bits);
 }
 
 /* Loop over each allocated buffer. */
@@ -405,13 +405,13 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io,
         */
 
        offset = block << v->data_dev_block_bits;
-       res = div64_u64(offset, v->fec->rounds << v->data_dev_block_bits);
+       res = div64_u64(offset, v->fec->region_blocks << v->data_dev_block_bits);
 
        /*
         * The base RS block we can feed to the interleaver to find out all
         * blocks required for decoding.
         */
-       rsb = offset - res * (v->fec->rounds << v->data_dev_block_bits);
+       rsb = offset - res * (v->fec->region_blocks << v->data_dev_block_bits);
 
        /*
         * Locating erasures is slow, so attempt to recover the block without
@@ -659,15 +659,15 @@ int verity_fec_ctr(struct dm_verity *v)
                return -EINVAL;
        }
 
-       f->rounds = f->blocks;
-       if (sector_div(f->rounds, f->rs_k))
-               f->rounds++;
+       f->region_blocks = f->blocks;
+       if (sector_div(f->region_blocks, f->rs_k))
+               f->region_blocks++;
 
        /*
         * Due to optional metadata, f->blocks can be larger than
         * data_blocks and hash_blocks combined.
         */
-       if (f->blocks < v->data_blocks + hash_blocks || !f->rounds) {
+       if (f->blocks < v->data_blocks + hash_blocks || !f->region_blocks) {
                ti->error = "Invalid " DM_VERITY_OPT_FEC_BLOCKS;
                return -EINVAL;
        }
@@ -693,7 +693,7 @@ int verity_fec_ctr(struct dm_verity *v)
 
        dm_bufio_set_sector_offset(f->bufio, f->start << (v->data_dev_block_bits - SECTOR_SHIFT));
 
-       if (dm_bufio_get_device_size(f->bufio) < f->rounds * f->roots) {
+       if (dm_bufio_get_device_size(f->bufio) < f->region_blocks * f->roots) {
                ti->error = "FEC device is too small";
                return -E2BIG;
        }
index 49d43894ea74699b5144fd606cb4515c45579058..50b5e187d5cc1b0091f018e0749e96b540b9e1e9 100644 (file)
@@ -32,7 +32,7 @@ struct dm_verity_fec {
        size_t block_size;      /* size of data, hash, and parity blocks in bytes */
        sector_t start;         /* parity data start in blocks */
        sector_t blocks;        /* number of blocks covered */
-       sector_t rounds;        /* number of interleaving rounds */
+       sector_t region_blocks; /* blocks per region: ceil(blocks / rs_k) */
        sector_t hash_blocks;   /* blocks covered after v->hash_start */
        unsigned char roots;    /* parity bytes per RS codeword, n-k of RS(n, k) */
        unsigned char rs_k;     /* message bytes per RS codeword, k of RS(n, k) */