dm verity fec: Don't add data_blocks to block
A message that is not in the archive (sent off-list or not yet received): CGME20200407065340epcas1p13e6e5ad6131f0a94d3ed1e8360353a82@epcas1p1.samsung.com
PATCH 1/1 dm verity fec: Don't add data_blocks to block
Even if block type is metadata,
block in verity_fec_decode() has already the right block number. So there is no need to add data_blocks to block.
--- drivers/md/dm-verity-fec.c | 6 +----- drivers/md/dm-verity-fec.h | 4 +--- drivers/md/dm-verity-target.c | 4 +--- 3 files changed, 3 insertions(+), 11 deletions(-)
drivers/md/dm-verity-fec.c +0 -0
@@ -417,8 +417,7 @@ static int fec_bv_copy(struct dm_verity *v, struct
dm_verity_io *io, u8 *data,
* otherwise to a bio_vec starting from iter.
*/
int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io,
- enum verity_block_type type, sector_t block, u8 *dest, - struct bvec_iter *iter)
+ sector_t block, u8 *dest, struct bvec_iter *iter)
{
int r;
struct dm_verity_fec_io *fio = fec_io(io);
@@ -434,9 +433,6 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io,
fio->level++;
- if (type == DM_VERITY_BLOCK_TYPE_METADATA)
- block += v->data_blocks;
-
/*
* For RS(M, N), the continuous FEC data is divided into blocks of N
* bytes. Since block size may not be divisible by N, the last block
drivers/md/dm-verity-fec.h +1 -2
@@ -68,8 +68,7 @@ struct dm_verity_fec_io { extern bool verity_fec_is_enabled(struct dm_verity *v); extern int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io, - enum verity_block_type type, sector_t block, - u8 *dest, struct bvec_iter *iter); + sector_t block, u8 *dest, struct bvec_iter *iter); extern unsigned verity_fec_status_table(struct dm_verity *v, unsigned sz, char *result, unsigned maxlen);
@@ -98,7 +97,6 @@ static inline bool verity_fec_is_enabled(struct
dm_verity *v)
static inline int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io,
- enum verity_block_type type,
sector_t block, u8 *dest, struct bvec_iter *iter)
{
drivers/md/dm-verity-target.c +0 -0
@@ -303,7 +303,6 @@ static int verity_verify_level(struct dm_verity *v,
struct dm_verity_io *io,
v->digest_size) == 0)) aux->hash_verified = 1;
else if (verity_fec_decode(v, io,
- DM_VERITY_BLOCK_TYPE_METADATA,
hash_block, data, NULL) == 0) aux->hash_verified = 1;
else if (verity_handle_err(v,
@@ -521,8 +520,7 @@ static int verity_verify_io(struct dm_verity_io *io)
if (v->validated_blocks)
set_bit(cur_block, v->validated_blocks); continue;
- }
- else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_DATA, + } else if (verity_fec_decode(v, io,
cur_block, NULL, &start) == 0) continue;
else if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
Signature · 1 line
2.17.1
Quoted 4 lines · Sunwook Eom
Even if block type is metadata,
block inverity_fec_decode()has already the right block number. So there is no need to adddata_blocksto block.
Is this also true if the hashes are on a separate block device?
The idea here is that the error correction data was computed over both data and hash blocks, as if they were concatenated, and we want to calculate the logical block number based on that. I agree that the code doesn't look quite right though. Should we use something like this instead?
if (type == DM_VERITY_BLOCK_TYPE_METADATA)
block = block - v->hash_start + v->data_blocks;Sami
Quoted 12 lines · Sami Tolvanen
Quoted 3 lines · Sunwook Eom
Even if block type is metadata,
block inverity_fec_decode()has already the right block number. So there is no need to adddata_blocksto block.Is this also true if the hashes are on a separate block device?
The idea here is that the error correction data was computed over both data and hash blocks, as if they were concatenated, and we want to calculate the logical block number based on that. I agree that the code doesn't look quite right though. Should we use something like this instead?
Quoted 6 lines
if (type == DM_VERITY_BLOCK_TYPE_METADATA) block = block - v->hash_start + v->data_blocks;Sami
You're right. I missed the case that hashes are on a separate block device.
And, the code you wrote seems to be correct.
If you don't mind, I'll send a new version of this patch.
Thank you for the review.
Sunwook
Quoted 1 line · Sunwook Eom
If you don't mind, I'll send a new version of this patch.
Sounds good, thanks! Please also add a Fixes tag to the next version:
Sami