Commit 2f9941b6c55d70103c1bc3f2c7676acd9f20bf8a
Committed by
Linus Torvalds
1 parent
98221eb757
Exists in
master
and in
7 other branches
dm crypt: fix remove first_clone
Get rid of first_clone in dm-crypt This gets rid of first_clone, which is not really needed. Apparently, cloned bios used to share their bvec some time way in the past - this is no longer the case. Contrarily, this even hurts us if we try to create a clone off first_clone after it has completed, and crypt_endio has destroyed its bvec. Signed-off-by: Olaf Kirch <olaf.kirch@oracle.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Cc: Jens Axboe <jens.axboe@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 6 additions and 28 deletions Side-by-side Diff
drivers/md/dm-crypt.c
... | ... | @@ -33,7 +33,6 @@ |
33 | 33 | struct crypt_io { |
34 | 34 | struct dm_target *target; |
35 | 35 | struct bio *base_bio; |
36 | - struct bio *first_clone; | |
37 | 36 | struct work_struct work; |
38 | 37 | atomic_t pending; |
39 | 38 | int error; |
... | ... | @@ -380,9 +379,8 @@ |
380 | 379 | * This should never violate the device limitations |
381 | 380 | * May return a smaller bio when running out of pages |
382 | 381 | */ |
383 | -static struct bio * | |
384 | -crypt_alloc_buffer(struct crypt_io *io, unsigned int size, | |
385 | - struct bio *base_bio, unsigned int *bio_vec_idx) | |
382 | +static struct bio *crypt_alloc_buffer(struct crypt_io *io, unsigned int size, | |
383 | + unsigned int *bio_vec_idx) | |
386 | 384 | { |
387 | 385 | struct crypt_config *cc = io->target->private; |
388 | 386 | struct bio *clone; |
... | ... | @@ -390,12 +388,7 @@ |
390 | 388 | gfp_t gfp_mask = GFP_NOIO | __GFP_HIGHMEM; |
391 | 389 | unsigned int i; |
392 | 390 | |
393 | - if (base_bio) { | |
394 | - clone = bio_alloc_bioset(GFP_NOIO, base_bio->bi_max_vecs, cc->bs); | |
395 | - __bio_clone(clone, base_bio); | |
396 | - } else | |
397 | - clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, cc->bs); | |
398 | - | |
391 | + clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, cc->bs); | |
399 | 392 | if (!clone) |
400 | 393 | return NULL; |
401 | 394 | |
... | ... | @@ -498,9 +491,6 @@ |
498 | 491 | if (!atomic_dec_and_test(&io->pending)) |
499 | 492 | return; |
500 | 493 | |
501 | - if (io->first_clone) | |
502 | - bio_put(io->first_clone); | |
503 | - | |
504 | 494 | bio_endio(io->base_bio, io->base_bio->bi_size, io->error); |
505 | 495 | |
506 | 496 | mempool_free(io, cc->io_pool); |
... | ... | @@ -618,8 +608,7 @@ |
618 | 608 | * so repeat the whole process until all the data can be handled. |
619 | 609 | */ |
620 | 610 | while (remaining) { |
621 | - clone = crypt_alloc_buffer(io, base_bio->bi_size, | |
622 | - io->first_clone, &bvec_idx); | |
611 | + clone = crypt_alloc_buffer(io, base_bio->bi_size, &bvec_idx); | |
623 | 612 | if (unlikely(!clone)) { |
624 | 613 | dec_pending(io, -ENOMEM); |
625 | 614 | return; |
626 | 615 | |
... | ... | @@ -635,21 +624,11 @@ |
635 | 624 | } |
636 | 625 | |
637 | 626 | clone->bi_sector = cc->start + sector; |
638 | - | |
639 | - if (!io->first_clone) { | |
640 | - /* | |
641 | - * hold a reference to the first clone, because it | |
642 | - * holds the bio_vec array and that can't be freed | |
643 | - * before all other clones are released | |
644 | - */ | |
645 | - bio_get(clone); | |
646 | - io->first_clone = clone; | |
647 | - } | |
648 | - | |
649 | 627 | remaining -= clone->bi_size; |
650 | 628 | sector += bio_sectors(clone); |
651 | 629 | |
652 | - /* prevent bio_put of first_clone */ | |
630 | + /* Grab another reference to the io struct | |
631 | + * before we kick off the request */ | |
653 | 632 | if (remaining) |
654 | 633 | atomic_inc(&io->pending); |
655 | 634 | |
... | ... | @@ -965,7 +944,6 @@ |
965 | 944 | io = mempool_alloc(cc->io_pool, GFP_NOIO); |
966 | 945 | io->target = ti; |
967 | 946 | io->base_bio = bio; |
968 | - io->first_clone = NULL; | |
969 | 947 | io->error = io->post_process = 0; |
970 | 948 | atomic_set(&io->pending, 0); |
971 | 949 | kcryptd_queue_io(io); |