Messages in this thread | | | Date | Mon, 6 Jan 2020 19:14:29 -0800 | From | Eric Biggers <> | Subject | Re: [PATCH] dm-verity:unnecessary data blocks that need not read hash blocks |
| |
On Tue, Jan 07, 2020 at 10:48:43AM +0800, zhou_xianrong wrote:
> Subject: [PATCH] dm-verity:unnecessary data blocks that need not read
Please use a proper commit subject. It should begin with "dm verity: " and use the imperative tense to describe the change, e.g.
dm verity: don't prefetch hash blocks for already-verified data
Also this should have been "PATCH v2", not simply PATCH, since you already sent out a previous version.
You also sent out multiple copies of this email for some reason, so I just chose one arbitrarily to reply to...
> diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c > index 4fb33e7..4127711 100644 > --- a/drivers/md/dm-verity-target.c > +++ b/drivers/md/dm-verity-target.c > @@ -611,8 +611,27 @@ static void verity_prefetch_io(struct work_struct *work) > > static void verity_submit_prefetch(struct dm_verity *v, struct dm_verity_io *io) > { > + sector_t block = io->block; > + unsigned int n_blocks = io->n_blocks; > struct dm_verity_prefetch_work *pw; > > + if (v->validated_blocks) { > + while (n_blocks) { > + if (unlikely(!test_bit(block, v->validated_blocks))) > + break; > + block++; > + n_blocks--; > + } > + while (n_blocks) { > + if (unlikely(!test_bit(block + n_blocks - 1, > + v->validated_blocks))) > + break; > + n_blocks--; > + } > + if (!n_blocks) > + return; > + }
This looks fine now, though it's a bit more verbose than necessary, and I don't think unlikely() will make any difference here. Consider simplifying it to:
if (v->validated_blocks) { while (n_blocks && test_bit(block, v->validated_blocks)) { block++; n_blocks--; } while (n_blocks && test_bit(block + n_blocks - 1, v->validated_blocks)) n_blocks--; if (!n_blocks) return; }
| |