From: Eric Biggers <ebiggers@kernel.org>
To: dm-devel@lists.linux.dev, Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
Benjamin Marzinski <bmarzins@redhat.com>
Cc: Sami Tolvanen <samitolvanen@google.com>,
linux-kernel@vger.kernel.org, Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 12/22] dm-verity-fec: rename rounds to region_blocks
Date: Thu, 5 Feb 2026 20:59:31 -0800 [thread overview]
Message-ID: <20260206045942.52965-13-ebiggers@kernel.org> (raw)
In-Reply-To: <20260206045942.52965-1-ebiggers@kernel.org>
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>
---
drivers/md/dm-verity-fec.c | 16 ++++++++--------
drivers/md/dm-verity-fec.h | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c
index 6ba9a1e039be3..28b47497c3d3f 100644
--- a/drivers/md/dm-verity-fec.c
+++ b/drivers/md/dm-verity-fec.c
@@ -29,11 +29,11 @@ static inline unsigned int fec_max_nbufs(struct dm_verity *v)
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. */
#define fec_for_each_buffer(io, __i) \
for (__i = 0; __i < (io)->nbufs; __i++)
@@ -403,17 +403,17 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io,
* and each code is interleaved over k blocks to make it less likely
* that bursty corruption will leave us in unrecoverable state.
*/
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
* them first. Do a second attempt with erasures if the corruption is
* bad enough.
@@ -657,19 +657,19 @@ int verity_fec_ctr(struct dm_verity *v)
if (!f->blocks) {
ti->error = "Missing " DM_VERITY_OPT_FEC_BLOCKS;
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;
}
/*
@@ -691,11 +691,11 @@ int verity_fec_ctr(struct dm_verity *v)
return PTR_ERR(f->bufio);
}
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;
}
f->data_bufio = dm_bufio_client_create(v->data_dev->bdev, f->block_size,
diff --git a/drivers/md/dm-verity-fec.h b/drivers/md/dm-verity-fec.h
index 49d43894ea746..50b5e187d5cc1 100644
--- a/drivers/md/dm-verity-fec.h
+++ b/drivers/md/dm-verity-fec.h
@@ -30,11 +30,11 @@ struct dm_verity_fec {
struct dm_bufio_client *data_bufio; /* for data dev access */
struct dm_bufio_client *bufio; /* for parity data access */
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) */
mempool_t fio_pool; /* mempool for dm_verity_fec_io */
mempool_t rs_pool; /* mempool for fio->rs */
--
2.52.0
next prev parent reply other threads:[~2026-02-06 5:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 4:59 [PATCH 00/22] dm-verity: more FEC fixes and cleanups Eric Biggers
2026-02-06 4:59 ` [PATCH 01/22] dm-verity-fec: correctly reject too-small FEC devices Eric Biggers
2026-02-06 4:59 ` [PATCH 02/22] dm-verity-fec: correctly reject too-small hash devices Eric Biggers
2026-02-06 4:59 ` [PATCH 03/22] dm-verity-fec: fix corrected block count stat Eric Biggers
2026-02-06 4:59 ` [PATCH 04/22] dm-verity-fec: fix the size of dm_verity_fec_io::erasures Eric Biggers
2026-02-06 4:59 ` [PATCH 05/22] dm-verity-fec: fix reading parity bytes split across blocks (take 3) Eric Biggers
2026-02-06 4:59 ` [PATCH 06/22] dm-verity: rename dm_verity::hash_blocks to dm_verity::hash_end Eric Biggers
2026-02-06 4:59 ` [PATCH 07/22] dm-verity-fec: improve documentation for Forward Error Correction Eric Biggers
2026-02-06 4:59 ` [PATCH 08/22] dm-verity-fec: replace {MAX,MIN}_RSN with {MIN,MAX}_ROOTS Eric Biggers
2026-02-06 4:59 ` [PATCH 09/22] dm-verity-fec: use standard names for Reed-Solomon parameters Eric Biggers
2026-02-06 4:59 ` [PATCH 10/22] dm-verity-fec: rename "RS block" to "RS codeword" Eric Biggers
2026-02-06 4:59 ` [PATCH 11/22] dm-verity-fec: replace io_size with block_size Eric Biggers
2026-02-06 4:59 ` Eric Biggers [this message]
2026-02-06 4:59 ` [PATCH 13/22] dm-verity-fec: simplify computation of rsb Eric Biggers
2026-02-06 4:59 ` [PATCH 14/22] dm-verity-fec: simplify computation of ileaved Eric Biggers
2026-02-06 4:59 ` [PATCH 15/22] dm-verity-fec: simplify deinterleaving Eric Biggers
2026-02-06 4:59 ` [PATCH 16/22] dm-verity-fec: rename block_offset to out_pos Eric Biggers
2026-02-06 4:59 ` [PATCH 17/22] dm-verity-fec: move computation of offset and rsb down a level Eric Biggers
2026-02-06 4:59 ` [PATCH 18/22] dm-verity-fec: compute target region directly Eric Biggers
2026-02-06 4:59 ` [PATCH 19/22] dm-verity-fec: pass down index_in_region instead of rsb Eric Biggers
2026-02-06 4:59 ` [PATCH 20/22] dm-verity-fec: make fec_decode_bufs() just return 0 or error Eric Biggers
2026-02-06 4:59 ` [PATCH 21/22] dm-verity-fec: log target_block instead of index_in_region Eric Biggers
2026-02-06 4:59 ` [PATCH 22/22] dm-verity-fec: improve comments for fec_read_bufs() Eric Biggers
2026-02-11 22:29 ` [PATCH 00/22] dm-verity: more FEC fixes and cleanups Sami Tolvanen
2026-03-03 20:16 ` Eric Biggers
2026-03-04 8:25 ` Milan Broz
2026-03-04 9:00 ` Eric Biggers
2026-03-04 9:34 ` Milan Broz
2026-03-04 17:45 ` Eric Biggers
2026-03-04 19:29 ` Milan Broz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260206045942.52965-13-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=samitolvanen@google.com \
--cc=snitzer@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox