Commit 132a4161 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix raid0 readahead size

From: Arjan van de Ven <arjanv@redhat.com>

Readahead of raid0 was suboptimal; it read only 1 stride ahead.  The
problem with this is that while it will keep all spindles busy, it will not
actually manage to make larger IO's, eg each disk would just do the chunk
size IO.  Doing at least 2 chunks is more than appropriate so that each
spindle will get a chance to merge IO's.

(Neil fixed raid6 and raid6 too)
parent ef3555ba
...@@ -313,8 +313,8 @@ static int raid0_run (mddev_t *mddev) ...@@ -313,8 +313,8 @@ static int raid0_run (mddev_t *mddev)
/* calculate the max read-ahead size. /* calculate the max read-ahead size.
* For read-ahead of large files to be effective, we need to * For read-ahead of large files to be effective, we need to
* readahead at least a whole stripe. i.e. number of devices * readahead at least twice a whole stripe. i.e. number of devices
* multiplied by chunk size. * multiplied by chunk size times 2.
* If an individual device has an ra_pages greater than the * If an individual device has an ra_pages greater than the
* chunk size, then we will not drive that device as hard as it * chunk size, then we will not drive that device as hard as it
* wants. We consider this a configuration error: a larger * wants. We consider this a configuration error: a larger
...@@ -322,8 +322,8 @@ static int raid0_run (mddev_t *mddev) ...@@ -322,8 +322,8 @@ static int raid0_run (mddev_t *mddev)
*/ */
{ {
int stripe = mddev->raid_disks * mddev->chunk_size / PAGE_CACHE_SIZE; int stripe = mddev->raid_disks * mddev->chunk_size / PAGE_CACHE_SIZE;
if (mddev->queue->backing_dev_info.ra_pages < stripe) if (mddev->queue->backing_dev_info.ra_pages < 2* stripe)
mddev->queue->backing_dev_info.ra_pages = stripe; mddev->queue->backing_dev_info.ra_pages = 2* stripe;
} }
......
...@@ -1602,14 +1602,14 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) + ...@@ -1602,14 +1602,14 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
print_raid5_conf(conf); print_raid5_conf(conf);
/* read-ahead size must cover a whole stripe, which is /* read-ahead size must cover two whole stripes, which is
* (n-1) * chunksize where 'n' is the number of raid devices * 2 * (n-1) * chunksize where 'n' is the number of raid devices
*/ */
{ {
int stripe = (mddev->raid_disks-1) * mddev->chunk_size int stripe = (mddev->raid_disks-1) * mddev->chunk_size
/ PAGE_CACHE_SIZE; / PAGE_CACHE_SIZE;
if (mddev->queue->backing_dev_info.ra_pages < stripe) if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe)
mddev->queue->backing_dev_info.ra_pages = stripe; mddev->queue->backing_dev_info.ra_pages = 2 * stripe;
} }
/* Ok, everything is just fine now */ /* Ok, everything is just fine now */
......
...@@ -1771,14 +1771,14 @@ static int run (mddev_t *mddev) ...@@ -1771,14 +1771,14 @@ static int run (mddev_t *mddev)
print_raid6_conf(conf); print_raid6_conf(conf);
/* read-ahead size must cover a whole stripe, which is /* read-ahead size must cover two whole stripes, which is
* (n-2) * chunksize where 'n' is the number of raid devices * 2 * (n-2) * chunksize where 'n' is the number of raid devices
*/ */
{ {
int stripe = (mddev->raid_disks-2) * mddev->chunk_size int stripe = (mddev->raid_disks-2) * mddev->chunk_size
/ PAGE_CACHE_SIZE; / PAGE_CACHE_SIZE;
if (mddev->queue->backing_dev_info.ra_pages < stripe) if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe)
mddev->queue->backing_dev_info.ra_pages = stripe; mddev->queue->backing_dev_info.ra_pages = 2 * stripe;
} }
/* Ok, everything is just fine now */ /* Ok, everything is just fine now */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment