dm crypt: add merge
authorMilan Broz <mbroz@redhat.com>
Mon, 21 Jul 2008 11:00:40 +0000 (12:00 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Mon, 21 Jul 2008 11:00:40 +0000 (12:00 +0100)
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>
drivers/md/dm-crypt.c

index ab6a61db63ce2248b5553ec43678fab61642e9a7..13956437bc81888d38e89ba2abbaa8d62772fc52 100644 (file)
@@ -1216,9 +1216,24 @@ error:
        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,
@@ -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)