aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2008-07-21 07:00:38 -0400
committerAlasdair G Kergon <agk@redhat.com>2008-07-21 07:00:38 -0400
commit7bc3447b692185c5ea78bee93d0ef1dee2fd7ce7 (patch)
treef30ddd021bcbb333f12b1a57a6969e0d52b7cdab /drivers/md
parentf6fccb1213ba3d661baeb2a5eee0a9701dc03e1b (diff)
dm: linear add merge
This patch implements biovec merge function for linear 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>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-linear.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index 17753d80ad2..6449bcdf84c 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -69,13 +69,25 @@ static void linear_dtr(struct dm_target *ti)
69 kfree(lc); 69 kfree(lc);
70} 70}
71 71
72static int linear_map(struct dm_target *ti, struct bio *bio, 72static sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector)
73 union map_info *map_context)
74{ 73{
75 struct linear_c *lc = (struct linear_c *) ti->private; 74 struct linear_c *lc = ti->private;
75
76 return lc->start + (bi_sector - ti->begin);
77}
78
79static void linear_map_bio(struct dm_target *ti, struct bio *bio)
80{
81 struct linear_c *lc = ti->private;
76 82
77 bio->bi_bdev = lc->dev->bdev; 83 bio->bi_bdev = lc->dev->bdev;
78 bio->bi_sector = lc->start + (bio->bi_sector - ti->begin); 84 bio->bi_sector = linear_map_sector(ti, bio->bi_sector);
85}
86
87static int linear_map(struct dm_target *ti, struct bio *bio,
88 union map_info *map_context)
89{
90 linear_map_bio(ti, bio);
79 91
80 return DM_MAPIO_REMAPPED; 92 return DM_MAPIO_REMAPPED;
81} 93}
@@ -114,15 +126,31 @@ static int linear_ioctl(struct dm_target *ti, struct inode *inode,
114 return blkdev_driver_ioctl(bdev->bd_inode, &fake_file, bdev->bd_disk, cmd, arg); 126 return blkdev_driver_ioctl(bdev->bd_inode, &fake_file, bdev->bd_disk, cmd, arg);
115} 127}
116 128
129static int linear_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
130 struct bio_vec *biovec, int max_size)
131{
132 struct linear_c *lc = ti->private;
133 struct request_queue *q = bdev_get_queue(lc->dev->bdev);
134
135 if (!q->merge_bvec_fn)
136 return max_size;
137
138 bvm->bi_bdev = lc->dev->bdev;
139 bvm->bi_sector = linear_map_sector(ti, bvm->bi_sector);
140
141 return min(max_size, q->merge_bvec_fn(q, bvm, biovec));
142}
143
117static struct target_type linear_target = { 144static struct target_type linear_target = {
118 .name = "linear", 145 .name = "linear",
119 .version= {1, 0, 2}, 146 .version= {1, 0, 3},
120 .module = THIS_MODULE, 147 .module = THIS_MODULE,
121 .ctr = linear_ctr, 148 .ctr = linear_ctr,
122 .dtr = linear_dtr, 149 .dtr = linear_dtr,
123 .map = linear_map, 150 .map = linear_map,
124 .status = linear_status, 151 .status = linear_status,
125 .ioctl = linear_ioctl, 152 .ioctl = linear_ioctl,
153 .merge = linear_merge,
126}; 154};
127 155
128int __init dm_linear_init(void) 156int __init dm_linear_init(void)