diff options
author | Milan Broz <mbroz@redhat.com> | 2008-02-07 21:10:38 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2008-02-07 21:10:38 -0500 |
commit | 53017030e2548dffbe481fb4ab6b587abbee6f8b (patch) | |
tree | 83831c963242bfafb6c753960ef3a50b3fd1e314 /drivers/md/dm-crypt.c | |
parent | 009cd09042fbd095e708b412ad7870fb421fa2f0 (diff) |
dm crypt: move convert_context inside dm_crypt_io
Move convert_context inside dm_crypt_io.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-crypt.c')
-rw-r--r-- | drivers/md/dm-crypt.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 6b66ee46b87d..af8cd99daa5b 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -28,17 +28,6 @@ | |||
28 | #define MESG_STR(x) x, sizeof(x) | 28 | #define MESG_STR(x) x, sizeof(x) |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * per bio private data | ||
32 | */ | ||
33 | struct dm_crypt_io { | ||
34 | struct dm_target *target; | ||
35 | struct bio *base_bio; | ||
36 | struct work_struct work; | ||
37 | atomic_t pending; | ||
38 | int error; | ||
39 | }; | ||
40 | |||
41 | /* | ||
42 | * context holding the current state of a multi-part conversion | 31 | * context holding the current state of a multi-part conversion |
43 | */ | 32 | */ |
44 | struct convert_context { | 33 | struct convert_context { |
@@ -52,6 +41,20 @@ struct convert_context { | |||
52 | int write; | 41 | int write; |
53 | }; | 42 | }; |
54 | 43 | ||
44 | /* | ||
45 | * per bio private data | ||
46 | */ | ||
47 | struct dm_crypt_io { | ||
48 | struct dm_target *target; | ||
49 | struct bio *base_bio; | ||
50 | struct work_struct work; | ||
51 | |||
52 | struct convert_context ctx; | ||
53 | |||
54 | atomic_t pending; | ||
55 | int error; | ||
56 | }; | ||
57 | |||
55 | struct crypt_config; | 58 | struct crypt_config; |
56 | 59 | ||
57 | struct crypt_iv_operations { | 60 | struct crypt_iv_operations { |
@@ -579,13 +582,12 @@ static void process_write(struct dm_crypt_io *io) | |||
579 | struct crypt_config *cc = io->target->private; | 582 | struct crypt_config *cc = io->target->private; |
580 | struct bio *base_bio = io->base_bio; | 583 | struct bio *base_bio = io->base_bio; |
581 | struct bio *clone; | 584 | struct bio *clone; |
582 | struct convert_context ctx; | ||
583 | unsigned remaining = base_bio->bi_size; | 585 | unsigned remaining = base_bio->bi_size; |
584 | sector_t sector = base_bio->bi_sector - io->target->begin; | 586 | sector_t sector = base_bio->bi_sector - io->target->begin; |
585 | 587 | ||
586 | atomic_inc(&io->pending); | 588 | atomic_inc(&io->pending); |
587 | 589 | ||
588 | crypt_convert_init(cc, &ctx, NULL, base_bio, sector, 1); | 590 | crypt_convert_init(cc, &io->ctx, NULL, base_bio, sector, 1); |
589 | 591 | ||
590 | /* | 592 | /* |
591 | * The allocated buffers can be smaller than the whole bio, | 593 | * The allocated buffers can be smaller than the whole bio, |
@@ -598,10 +600,10 @@ static void process_write(struct dm_crypt_io *io) | |||
598 | return; | 600 | return; |
599 | } | 601 | } |
600 | 602 | ||
601 | ctx.bio_out = clone; | 603 | io->ctx.bio_out = clone; |
602 | ctx.idx_out = 0; | 604 | io->ctx.idx_out = 0; |
603 | 605 | ||
604 | if (unlikely(crypt_convert(cc, &ctx) < 0)) { | 606 | if (unlikely(crypt_convert(cc, &io->ctx) < 0)) { |
605 | crypt_free_buffer_pages(cc, clone); | 607 | crypt_free_buffer_pages(cc, clone); |
606 | bio_put(clone); | 608 | bio_put(clone); |
607 | crypt_dec_pending(io, -EIO); | 609 | crypt_dec_pending(io, -EIO); |
@@ -609,7 +611,7 @@ static void process_write(struct dm_crypt_io *io) | |||
609 | } | 611 | } |
610 | 612 | ||
611 | /* crypt_convert should have filled the clone bio */ | 613 | /* crypt_convert should have filled the clone bio */ |
612 | BUG_ON(ctx.idx_out < clone->bi_vcnt); | 614 | BUG_ON(io->ctx.idx_out < clone->bi_vcnt); |
613 | 615 | ||
614 | clone->bi_sector = cc->start + sector; | 616 | clone->bi_sector = cc->start + sector; |
615 | remaining -= clone->bi_size; | 617 | remaining -= clone->bi_size; |
@@ -634,12 +636,11 @@ static void process_write(struct dm_crypt_io *io) | |||
634 | static void process_read_endio(struct dm_crypt_io *io) | 636 | static void process_read_endio(struct dm_crypt_io *io) |
635 | { | 637 | { |
636 | struct crypt_config *cc = io->target->private; | 638 | struct crypt_config *cc = io->target->private; |
637 | struct convert_context ctx; | ||
638 | 639 | ||
639 | crypt_convert_init(cc, &ctx, io->base_bio, io->base_bio, | 640 | crypt_convert_init(cc, &io->ctx, io->base_bio, io->base_bio, |
640 | io->base_bio->bi_sector - io->target->begin, 0); | 641 | io->base_bio->bi_sector - io->target->begin, 0); |
641 | 642 | ||
642 | crypt_dec_pending(io, crypt_convert(cc, &ctx)); | 643 | crypt_dec_pending(io, crypt_convert(cc, &io->ctx)); |
643 | } | 644 | } |
644 | 645 | ||
645 | static void kcryptd_do_work(struct work_struct *work) | 646 | static void kcryptd_do_work(struct work_struct *work) |