Skip to content

Commit e9307e3

Browse files
author
Mike Snitzer
committed
dm verity: only copy bvec_iter in verity_verify_io if in_tasklet
Avoid extra bvec_iter copy unless it is needed to allow retrying verification, that failed from a tasklet, from a workqueue. Signed-off-by: Mike Snitzer <[email protected]>
1 parent 0a36463 commit e9307e3

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

drivers/md/dm-verity-target.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -501,23 +501,30 @@ static int verity_verify_io(struct dm_verity_io *io)
501501
#if defined(CONFIG_DM_VERITY_FEC)
502502
struct bvec_iter start;
503503
#endif
504-
/*
505-
* Copy the iterator in case we need to restart verification in a
506-
* work-queue.
507-
*/
508-
struct bvec_iter iter_copy = io->iter;
504+
struct bvec_iter iter_copy;
505+
struct bvec_iter *iter;
509506
struct crypto_wait wait;
510507
struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
511508
unsigned int b;
512509

510+
if (static_branch_unlikely(&use_tasklet_enabled) && io->in_tasklet) {
511+
/*
512+
* Copy the iterator in case we need to restart
513+
* verification in a work-queue.
514+
*/
515+
iter_copy = io->iter;
516+
iter = &iter_copy;
517+
} else
518+
iter = &io->iter;
519+
513520
for (b = 0; b < io->n_blocks; b++) {
514521
int r;
515522
sector_t cur_block = io->block + b;
516523
struct ahash_request *req = verity_io_hash_req(v, io);
517524

518525
if (v->validated_blocks &&
519526
likely(test_bit(cur_block, v->validated_blocks))) {
520-
verity_bv_skip_block(v, io, &iter_copy);
527+
verity_bv_skip_block(v, io, iter);
521528
continue;
522529
}
523530

@@ -532,7 +539,7 @@ static int verity_verify_io(struct dm_verity_io *io)
532539
* If we expect a zero block, don't validate, just
533540
* return zeros.
534541
*/
535-
r = verity_for_bv_block(v, io, &iter_copy,
542+
r = verity_for_bv_block(v, io, iter,
536543
verity_bv_zero);
537544
if (unlikely(r < 0))
538545
return r;
@@ -546,9 +553,9 @@ static int verity_verify_io(struct dm_verity_io *io)
546553

547554
#if defined(CONFIG_DM_VERITY_FEC)
548555
if (verity_fec_is_enabled(v))
549-
start = iter_copy;
556+
start = *iter;
550557
#endif
551-
r = verity_for_io_block(v, io, &iter_copy, &wait);
558+
r = verity_for_io_block(v, io, iter, &wait);
552559
if (unlikely(r < 0))
553560
return r;
554561

0 commit comments

Comments
 (0)