Skip to content

Commit

Permalink
dm crypt: add merge
Browse files Browse the repository at this point in the history
This patch implements biovec merge function for crypt target.

If the underlying device has merge function defined, call it.
If not, keep precomputed value.

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
  • Loading branch information
Milan Broz authored and Alasdair G Kergon committed Jul 21, 2008
1 parent 9980c63 commit d41e26b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,24 @@ static int crypt_message(struct dm_target *ti, unsigned argc, char **argv)
return -EINVAL;
}

static int crypt_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
struct bio_vec *biovec, int max_size)
{
struct crypt_config *cc = ti->private;
struct request_queue *q = bdev_get_queue(cc->dev->bdev);

if (!q->merge_bvec_fn)
return max_size;

bvm->bi_bdev = cc->dev->bdev;
bvm->bi_sector = cc->start + bvm->bi_sector - ti->begin;

return min(max_size, q->merge_bvec_fn(q, bvm, biovec));
}

static struct target_type crypt_target = {
.name = "crypt",
.version= {1, 5, 0},
.version= {1, 6, 0},
.module = THIS_MODULE,
.ctr = crypt_ctr,
.dtr = crypt_dtr,
Expand All @@ -1228,6 +1243,7 @@ static struct target_type crypt_target = {
.preresume = crypt_preresume,
.resume = crypt_resume,
.message = crypt_message,
.merge = crypt_merge,
};

static int __init dm_crypt_init(void)
Expand Down

0 comments on commit d41e26b

Please sign in to comment.