aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2008-02-07 21:10:54 -0500
committerAlasdair G Kergon <agk@redhat.com>2008-02-07 21:10:54 -0500
commit0c395b0f8dd7aee394df95b46963fc0f3401cf90 (patch)
tree03a83a7ba9e9917fadae5416ed58533e51e67067 /drivers/md
parent395b167ca0c559aa975d8bbc46a3d10edd6e17d0 (diff)
dm crypt: store sector mapping in dm_crypt_io
Add sector into dm_crypt_io instead of using local variable. Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-crypt.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index ccc2fe19db86..d3c48ad580d9 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -52,6 +52,7 @@ struct dm_crypt_io {
52 52
53 atomic_t pending; 53 atomic_t pending;
54 int error; 54 int error;
55 sector_t sector;
55}; 56};
56 57
57struct crypt_config; 58struct crypt_config;
@@ -526,7 +527,6 @@ static void kcryptd_io_read(struct dm_crypt_io *io)
526 struct crypt_config *cc = io->target->private; 527 struct crypt_config *cc = io->target->private;
527 struct bio *base_bio = io->base_bio; 528 struct bio *base_bio = io->base_bio;
528 struct bio *clone; 529 struct bio *clone;
529 sector_t sector = base_bio->bi_sector - io->target->begin;
530 530
531 atomic_inc(&io->pending); 531 atomic_inc(&io->pending);
532 532
@@ -546,7 +546,7 @@ static void kcryptd_io_read(struct dm_crypt_io *io)
546 clone->bi_idx = 0; 546 clone->bi_idx = 0;
547 clone->bi_vcnt = bio_segments(base_bio); 547 clone->bi_vcnt = bio_segments(base_bio);
548 clone->bi_size = base_bio->bi_size; 548 clone->bi_size = base_bio->bi_size;
549 clone->bi_sector = cc->start + sector; 549 clone->bi_sector = cc->start + io->sector;
550 memcpy(clone->bi_io_vec, bio_iovec(base_bio), 550 memcpy(clone->bi_io_vec, bio_iovec(base_bio),
551 sizeof(struct bio_vec) * clone->bi_vcnt); 551 sizeof(struct bio_vec) * clone->bi_vcnt);
552 552
@@ -585,11 +585,10 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
585 struct bio *base_bio = io->base_bio; 585 struct bio *base_bio = io->base_bio;
586 struct bio *clone; 586 struct bio *clone;
587 unsigned remaining = base_bio->bi_size; 587 unsigned remaining = base_bio->bi_size;
588 sector_t sector = base_bio->bi_sector - io->target->begin;
589 588
590 atomic_inc(&io->pending); 589 atomic_inc(&io->pending);
591 590
592 crypt_convert_init(cc, &io->ctx, NULL, base_bio, sector); 591 crypt_convert_init(cc, &io->ctx, NULL, base_bio, io->sector);
593 592
594 /* 593 /*
595 * The allocated buffers can be smaller than the whole bio, 594 * The allocated buffers can be smaller than the whole bio,
@@ -617,9 +616,9 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
617 /* crypt_convert should have filled the clone bio */ 616 /* crypt_convert should have filled the clone bio */
618 BUG_ON(io->ctx.idx_out < clone->bi_vcnt); 617 BUG_ON(io->ctx.idx_out < clone->bi_vcnt);
619 618
620 clone->bi_sector = cc->start + sector; 619 clone->bi_sector = cc->start + io->sector;
621 remaining -= clone->bi_size; 620 remaining -= clone->bi_size;
622 sector += bio_sectors(clone); 621 io->sector += bio_sectors(clone);
623 622
624 /* Grab another reference to the io struct 623 /* Grab another reference to the io struct
625 * before we kick off the request */ 624 * before we kick off the request */
@@ -651,7 +650,7 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)
651 int r = 0; 650 int r = 0;
652 651
653 crypt_convert_init(cc, &io->ctx, io->base_bio, io->base_bio, 652 crypt_convert_init(cc, &io->ctx, io->base_bio, io->base_bio,
654 io->base_bio->bi_sector - io->target->begin); 653 io->sector);
655 654
656 r = crypt_convert(cc, &io->ctx); 655 r = crypt_convert(cc, &io->ctx);
657 656
@@ -974,6 +973,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio,
974 io = mempool_alloc(cc->io_pool, GFP_NOIO); 973 io = mempool_alloc(cc->io_pool, GFP_NOIO);
975 io->target = ti; 974 io->target = ti;
976 io->base_bio = bio; 975 io->base_bio = bio;
976 io->sector = bio->bi_sector - ti->begin;
977 io->error = 0; 977 io->error = 0;
978 atomic_set(&io->pending, 0); 978 atomic_set(&io->pending, 0);
979 979