[PATCH] dm verity fec: Don't add data_blocks to block
From: Sunwook Eom
Date: Tue Apr 07 2020 - 02:53:47 EST
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.
Signed-off-by: Sunwook Eom <speed.eom@xxxxxxxxxxx>
---
Â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(-)
diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c
index 49147e634046..55f353cae6ec 100644
--- a/drivers/md/dm-verity-fec.c
+++ b/drivers/md/dm-verity-fec.c
@@ -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
diff --git a/drivers/md/dm-verity-fec.h b/drivers/md/dm-verity-fec.h
index 42fbd3a7fc9f..7e2fea0f8cbf 100644
--- a/drivers/md/dm-verity-fec.h
+++ b/drivers/md/dm-verity-fec.h
@@ -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)
Â{
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index eec9f252e935..a91b4cb2bf54 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -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,
--
2.17.1