diff options
author | Milan Broz <mbroz@redhat.com> | 2008-10-10 08:37:03 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2008-10-10 08:37:03 -0400 |
commit | dc440d1e56c481f80d5350daadc7d078a04ca729 (patch) | |
tree | 5d7c180f431820a6f1878177b5f59a500227bf1d | |
parent | 3e1a8bdd05d6b1734a8ccf7af28042d72c447780 (diff) |
dm crypt: tidy crypt alloc
Factor out crypt io allocation code.
Later patches will call it from another place.
No functional change.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r-- | drivers/md/dm-crypt.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 6b9be99eff5b..cac064d4aa72 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -517,6 +517,22 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) | |||
517 | } | 517 | } |
518 | } | 518 | } |
519 | 519 | ||
520 | static struct dm_crypt_io *crypt_io_alloc(struct dm_target *ti, | ||
521 | struct bio *bio, sector_t sector) | ||
522 | { | ||
523 | struct crypt_config *cc = ti->private; | ||
524 | struct dm_crypt_io *io; | ||
525 | |||
526 | io = mempool_alloc(cc->io_pool, GFP_NOIO); | ||
527 | io->target = ti; | ||
528 | io->base_bio = bio; | ||
529 | io->sector = sector; | ||
530 | io->error = 0; | ||
531 | atomic_set(&io->pending, 0); | ||
532 | |||
533 | return io; | ||
534 | } | ||
535 | |||
520 | static void crypt_inc_pending(struct dm_crypt_io *io) | 536 | static void crypt_inc_pending(struct dm_crypt_io *io) |
521 | { | 537 | { |
522 | atomic_inc(&io->pending); | 538 | atomic_inc(&io->pending); |
@@ -1113,15 +1129,9 @@ static void crypt_dtr(struct dm_target *ti) | |||
1113 | static int crypt_map(struct dm_target *ti, struct bio *bio, | 1129 | static int crypt_map(struct dm_target *ti, struct bio *bio, |
1114 | union map_info *map_context) | 1130 | union map_info *map_context) |
1115 | { | 1131 | { |
1116 | struct crypt_config *cc = ti->private; | ||
1117 | struct dm_crypt_io *io; | 1132 | struct dm_crypt_io *io; |
1118 | 1133 | ||
1119 | io = mempool_alloc(cc->io_pool, GFP_NOIO); | 1134 | io = crypt_io_alloc(ti, bio, bio->bi_sector - ti->begin); |
1120 | io->target = ti; | ||
1121 | io->base_bio = bio; | ||
1122 | io->sector = bio->bi_sector - ti->begin; | ||
1123 | io->error = 0; | ||
1124 | atomic_set(&io->pending, 0); | ||
1125 | 1135 | ||
1126 | if (bio_data_dir(io->base_bio) == READ) | 1136 | if (bio_data_dir(io->base_bio) == READ) |
1127 | kcryptd_queue_io(io); | 1137 | kcryptd_queue_io(io); |