diff options
author | Milan Broz <mbroz@redhat.com> | 2008-07-21 07:00:38 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2008-07-21 07:00:38 -0400 |
commit | 7bc3447b692185c5ea78bee93d0ef1dee2fd7ce7 (patch) | |
tree | f30ddd021bcbb333f12b1a57a6969e0d52b7cdab /drivers/md | |
parent | f6fccb1213ba3d661baeb2a5eee0a9701dc03e1b (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.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 17753d80ad22..6449bcdf84ca 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 | ||
72 | static int linear_map(struct dm_target *ti, struct bio *bio, | 72 | static 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 | |||
79 | static 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 | |||
87 | static 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 | ||
129 | static 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 | |||
117 | static struct target_type linear_target = { | 144 | static 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 | ||
128 | int __init dm_linear_init(void) | 156 | int __init dm_linear_init(void) |