[dm-devel] [PATCH] dm-verity: unnecessary data blocks that need not read hash blocks

zhou xianrong zhou_xianrong at yeah.net
Wed Dec 11 03:32:40 UTC 2019


From: "xianrong.zhou" <xianrong.zhou at transsion.com>

If check_at_most_once enabled, just like verity work the prefetching work
should check for data block bitmap firstly before reading hash block
as well. Skip bit-set data blocks from both ends of data block range
by testing the validated bitmap. This can reduce the amounts of data 
blocks which need to read hash blocks.

Launching 91 apps every 15s and repeat 21 rounds on Android Q.
In prefetching work we can let only 2602/360312 = 0.72% data blocks
really need to read hash blocks.

But the reduced data blocks range would be enlarged again by
dm_verity_prefetch_cluster later.

Signed-off-by: xianrong.zhou <xianrong.zhou at transsion.com>
Signed-off-by: yuanjiong.gao <yuanjiong.gao at transsion.com>
Tested-by: ruxian.feng <ruxian.feng at transsion.com>
---
 drivers/md/dm-verity-target.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index 4fb33e7562c5..7b8eb754c0b6 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -581,6 +581,22 @@ static void verity_prefetch_io(struct work_struct *work)
 	struct dm_verity *v = pw->v;
 	int i;
 
+	if (v->validated_blocks) {
+		while (pw->n_blocks) {
+			if (unlikely(!test_bit(pw->block, v->validated_blocks)))
+				break;
+			pw->block++;
+			pw->n_blocks--;
+		}
+		while (pw->n_blocks) {
+			if (unlikely(!test_bit(pw->block + pw->n_blocks - 1,
+				v->validated_blocks)))
+				break;
+			pw->n_blocks--;
+		}
+		if (!pw->n_blocks)
+			return;
+	}
 	for (i = v->levels - 2; i >= 0; i--) {
 		sector_t hash_block_start;
 		sector_t hash_block_end;
-- 
2.17.0





More information about the dm-devel mailing list