diff options
author | NeilBrown <neilb@suse.de> | 2010-03-30 21:07:16 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-04-26 10:48:03 -0400 |
commit | 11d0dfa8ce268e40b625e26537f21cf5b74007af (patch) | |
tree | c1b6533fec346cf7203c56ceafdfaa97fe8dcc03 | |
parent | e6813c83b2ef1fe0abb88fca3c4dfc4c5a01f473 (diff) |
md: deal with merge_bvec_fn in component devices better.
commit 627a2d3c29427637f4c5d31ccc7fcbd8d312cd71 upstream.
If a component device has a merge_bvec_fn then as we never call it
we must ensure we never need to. Currently this is done by setting
max_sector to 1 PAGE, however this does not stop a bio being created
with several sub-page iovecs that would violate the merge_bvec_fn.
So instead set max_phys_segments to 1 and set the segment boundary to the
same as a page boundary to ensure there is only ever one single-page
segment of IO requested at a time.
This can particularly be an issue when 'xen' is used as it is
known to submit multiple small buffers in a single bio.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/md/linear.c | 12 | ||||
-rw-r--r-- | drivers/md/multipath.c | 20 | ||||
-rw-r--r-- | drivers/md/raid0.c | 13 | ||||
-rw-r--r-- | drivers/md/raid10.c | 28 |
4 files changed, 43 insertions, 30 deletions
diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 00435bd20699..001317b50034 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c | |||
@@ -172,12 +172,14 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks) | |||
172 | disk_stack_limits(mddev->gendisk, rdev->bdev, | 172 | disk_stack_limits(mddev->gendisk, rdev->bdev, |
173 | rdev->data_offset << 9); | 173 | rdev->data_offset << 9); |
174 | /* as we don't honour merge_bvec_fn, we must never risk | 174 | /* as we don't honour merge_bvec_fn, we must never risk |
175 | * violating it, so limit ->max_sector to one PAGE, as | 175 | * violating it, so limit max_phys_segments to 1 lying within |
176 | * a one page request is never in violation. | 176 | * a single page. |
177 | */ | 177 | */ |
178 | if (rdev->bdev->bd_disk->queue->merge_bvec_fn && | 178 | if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { |
179 | queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) | 179 | blk_queue_max_phys_segments(mddev->queue, 1); |
180 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); | 180 | blk_queue_segment_boundary(mddev->queue, |
181 | PAGE_CACHE_SIZE - 1); | ||
182 | } | ||
181 | 183 | ||
182 | conf->array_sectors += rdev->sectors; | 184 | conf->array_sectors += rdev->sectors; |
183 | cnt++; | 185 | cnt++; |
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index 32a662fc55c9..f9ee99f9a94c 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c | |||
@@ -301,14 +301,16 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) | |||
301 | rdev->data_offset << 9); | 301 | rdev->data_offset << 9); |
302 | 302 | ||
303 | /* as we don't honour merge_bvec_fn, we must never risk | 303 | /* as we don't honour merge_bvec_fn, we must never risk |
304 | * violating it, so limit ->max_sector to one PAGE, as | 304 | * violating it, so limit ->max_phys_segments to one, lying |
305 | * a one page request is never in violation. | 305 | * within a single page. |
306 | * (Note: it is very unlikely that a device with | 306 | * (Note: it is very unlikely that a device with |
307 | * merge_bvec_fn will be involved in multipath.) | 307 | * merge_bvec_fn will be involved in multipath.) |
308 | */ | 308 | */ |
309 | if (q->merge_bvec_fn && | 309 | if (q->merge_bvec_fn) { |
310 | queue_max_sectors(q) > (PAGE_SIZE>>9)) | 310 | blk_queue_max_phys_segments(mddev->queue, 1); |
311 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); | 311 | blk_queue_segment_boundary(mddev->queue, |
312 | PAGE_CACHE_SIZE - 1); | ||
313 | } | ||
312 | 314 | ||
313 | conf->working_disks++; | 315 | conf->working_disks++; |
314 | mddev->degraded--; | 316 | mddev->degraded--; |
@@ -476,9 +478,11 @@ static int multipath_run (mddev_t *mddev) | |||
476 | /* as we don't honour merge_bvec_fn, we must never risk | 478 | /* as we don't honour merge_bvec_fn, we must never risk |
477 | * violating it, not that we ever expect a device with | 479 | * violating it, not that we ever expect a device with |
478 | * a merge_bvec_fn to be involved in multipath */ | 480 | * a merge_bvec_fn to be involved in multipath */ |
479 | if (rdev->bdev->bd_disk->queue->merge_bvec_fn && | 481 | if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { |
480 | queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) | 482 | blk_queue_max_phys_segments(mddev->queue, 1); |
481 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); | 483 | blk_queue_segment_boundary(mddev->queue, |
484 | PAGE_CACHE_SIZE - 1); | ||
485 | } | ||
482 | 486 | ||
483 | if (!test_bit(Faulty, &rdev->flags)) | 487 | if (!test_bit(Faulty, &rdev->flags)) |
484 | conf->working_disks++; | 488 | conf->working_disks++; |
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 77605cdceaf1..41ee9deed250 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -176,14 +176,15 @@ static int create_strip_zones(mddev_t *mddev) | |||
176 | disk_stack_limits(mddev->gendisk, rdev1->bdev, | 176 | disk_stack_limits(mddev->gendisk, rdev1->bdev, |
177 | rdev1->data_offset << 9); | 177 | rdev1->data_offset << 9); |
178 | /* as we don't honour merge_bvec_fn, we must never risk | 178 | /* as we don't honour merge_bvec_fn, we must never risk |
179 | * violating it, so limit ->max_sector to one PAGE, as | 179 | * violating it, so limit ->max_phys_segments to 1, lying within |
180 | * a one page request is never in violation. | 180 | * a single page. |
181 | */ | 181 | */ |
182 | 182 | ||
183 | if (rdev1->bdev->bd_disk->queue->merge_bvec_fn && | 183 | if (rdev1->bdev->bd_disk->queue->merge_bvec_fn) { |
184 | queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) | 184 | blk_queue_max_phys_segments(mddev->queue, 1); |
185 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); | 185 | blk_queue_segment_boundary(mddev->queue, |
186 | 186 | PAGE_CACHE_SIZE - 1); | |
187 | } | ||
187 | if (!smallest || (rdev1->sectors < smallest->sectors)) | 188 | if (!smallest || (rdev1->sectors < smallest->sectors)) |
188 | smallest = rdev1; | 189 | smallest = rdev1; |
189 | cnt++; | 190 | cnt++; |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index d119b7b75e71..047c468e3d28 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -1155,13 +1155,17 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1155 | 1155 | ||
1156 | disk_stack_limits(mddev->gendisk, rdev->bdev, | 1156 | disk_stack_limits(mddev->gendisk, rdev->bdev, |
1157 | rdev->data_offset << 9); | 1157 | rdev->data_offset << 9); |
1158 | /* as we don't honour merge_bvec_fn, we must never risk | 1158 | /* as we don't honour merge_bvec_fn, we must |
1159 | * violating it, so limit ->max_sector to one PAGE, as | 1159 | * never risk violating it, so limit |
1160 | * a one page request is never in violation. | 1160 | * ->max_phys_segments to one lying with a single |
1161 | * page, as a one page request is never in | ||
1162 | * violation. | ||
1161 | */ | 1163 | */ |
1162 | if (rdev->bdev->bd_disk->queue->merge_bvec_fn && | 1164 | if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { |
1163 | queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) | 1165 | blk_queue_max_phys_segments(mddev->queue, 1); |
1164 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); | 1166 | blk_queue_segment_boundary(mddev->queue, |
1167 | PAGE_CACHE_SIZE - 1); | ||
1168 | } | ||
1165 | 1169 | ||
1166 | p->head_position = 0; | 1170 | p->head_position = 0; |
1167 | rdev->raid_disk = mirror; | 1171 | rdev->raid_disk = mirror; |
@@ -2255,12 +2259,14 @@ static int run(mddev_t *mddev) | |||
2255 | disk_stack_limits(mddev->gendisk, rdev->bdev, | 2259 | disk_stack_limits(mddev->gendisk, rdev->bdev, |
2256 | rdev->data_offset << 9); | 2260 | rdev->data_offset << 9); |
2257 | /* as we don't honour merge_bvec_fn, we must never risk | 2261 | /* as we don't honour merge_bvec_fn, we must never risk |
2258 | * violating it, so limit ->max_sector to one PAGE, as | 2262 | * violating it, so limit max_phys_segments to 1 lying |
2259 | * a one page request is never in violation. | 2263 | * within a single page. |
2260 | */ | 2264 | */ |
2261 | if (rdev->bdev->bd_disk->queue->merge_bvec_fn && | 2265 | if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { |
2262 | queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) | 2266 | blk_queue_max_phys_segments(mddev->queue, 1); |
2263 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); | 2267 | blk_queue_segment_boundary(mddev->queue, |
2268 | PAGE_CACHE_SIZE - 1); | ||
2269 | } | ||
2264 | 2270 | ||
2265 | disk->head_position = 0; | 2271 | disk->head_position = 0; |
2266 | } | 2272 | } |