]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] md: set ra_pages for raid0/raid5 devices properly.
authorAndrew Morton <akpm@osdl.org>
Mon, 29 Dec 2003 13:51:44 +0000 (05:51 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 29 Dec 2003 13:51:44 +0000 (05:51 -0800)
From: NeilBrown <neilb@cse.unsw.edu.au>

stripe to be effective.  This patch sets ra_pages
appropriately.

drivers/md/raid0.c
drivers/md/raid5.c

index d2e7227429ec30aebfb5a066b798692d7fc49218..1c4600f4b7fe21b23d9068d3394937afe7eaae58 100644 (file)
@@ -311,6 +311,22 @@ static int raid0_run (mddev_t *mddev)
                conf->hash_spacing++;
        }
 
+       /* calculate the max read-ahead size.
+        * For read-ahead of large files to be effective, we need to
+        * readahead at least a whole stripe. i.e. number of devices
+        * multiplied by chunk size.
+        * If an individual device has an ra_pages greater than the
+        * chunk size, then we will not drive that device as hard as it
+        * wants.  We consider this a configuration error: a larger
+        * chunksize should be used in that case.
+        */
+       {
+               int stripe = mddev->raid_disks * mddev->chunk_size / PAGE_CACHE_SIZE;
+               if (mddev->queue->backing_dev_info.ra_pages < stripe)
+                       mddev->queue->backing_dev_info.ra_pages = stripe;
+       }
+
+
        blk_queue_merge_bvec(mddev->queue, raid0_mergeable_bvec);
        return 0;
 
index 8ea6bf99dc2998b3e24056090a2939d925fed04d..def75ad21669f487e510e6f156e61393a6676e59 100644 (file)
@@ -1587,6 +1587,16 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
 
        print_raid5_conf(conf);
 
+       /* read-ahead size must cover a whole stripe, which is
+        * (n-1) * chunksize where 'n' is the number of raid devices
+        */
+       {
+               int stripe = (mddev->raid_disks-1) * mddev->chunk_size
+                       / PAGE_CACHE_SIZE;
+               if (mddev->queue->backing_dev_info.ra_pages < stripe)
+                       mddev->queue->backing_dev_info.ra_pages = stripe;
+       }
+
        /* Ok, everything is just fine now */
        mddev->array_size =  mddev->size * (mddev->raid_disks - 1);
        return 0;