aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm-crypt.c41
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 */
33struct 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 */
44struct convert_context { 33struct 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 */
47struct 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
55struct crypt_config; 58struct crypt_config;
56 59
57struct crypt_iv_operations { 60struct 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)
634static void process_read_endio(struct dm_crypt_io *io) 636static 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
645static void kcryptd_do_work(struct work_struct *work) 646static void kcryptd_do_work(struct work_struct *work)