aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid10.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2011-07-18 03:38:49 -0400
committerNeilBrown <neilb@suse.de>2011-07-18 03:38:49 -0400
commitc65060ad4274f70048d62e0a86332cd3fd23f28d (patch)
tree5e6c3cfeb122da72e1bfa3bea07d8f16f453dc9f /drivers/md/raid10.c
parent778ca01852e6cc9ff335119b37a1938a978df384 (diff)
md/raid10: share pages between read and write bio's during recovery
When performing a recovery, only first 2 slots in r10_bio are in use, for read and write respectively. However all of pages in the write bio are never used and just replaced to read bio's when the read completes. Get rid of those unused pages and share read pages properly. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid10.c')
-rw-r--r--drivers/md/raid10.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index e434f1e8d223..3715e220e5e0 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -123,7 +123,14 @@ static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data)
123 for (j = 0 ; j < nalloc; j++) { 123 for (j = 0 ; j < nalloc; j++) {
124 bio = r10_bio->devs[j].bio; 124 bio = r10_bio->devs[j].bio;
125 for (i = 0; i < RESYNC_PAGES; i++) { 125 for (i = 0; i < RESYNC_PAGES; i++) {
126 page = alloc_page(gfp_flags); 126 if (j == 1 && !test_bit(MD_RECOVERY_SYNC,
127 &conf->mddev->recovery)) {
128 /* we can share bv_page's during recovery */
129 struct bio *rbio = r10_bio->devs[0].bio;
130 page = rbio->bi_io_vec[i].bv_page;
131 get_page(page);
132 } else
133 page = alloc_page(gfp_flags);
127 if (unlikely(!page)) 134 if (unlikely(!page))
128 goto out_free_pages; 135 goto out_free_pages;
129 136
@@ -1360,20 +1367,14 @@ done:
1360static void recovery_request_write(mddev_t *mddev, r10bio_t *r10_bio) 1367static void recovery_request_write(mddev_t *mddev, r10bio_t *r10_bio)
1361{ 1368{
1362 conf_t *conf = mddev->private; 1369 conf_t *conf = mddev->private;
1363 int i, d; 1370 int d;
1364 struct bio *bio, *wbio; 1371 struct bio *wbio;
1365
1366 1372
1367 /* move the pages across to the second bio 1373 /*
1374 * share the pages with the first bio
1368 * and submit the write request 1375 * and submit the write request
1369 */ 1376 */
1370 bio = r10_bio->devs[0].bio;
1371 wbio = r10_bio->devs[1].bio; 1377 wbio = r10_bio->devs[1].bio;
1372 for (i=0; i < wbio->bi_vcnt; i++) {
1373 struct page *p = bio->bi_io_vec[i].bv_page;
1374 bio->bi_io_vec[i].bv_page = wbio->bi_io_vec[i].bv_page;
1375 wbio->bi_io_vec[i].bv_page = p;
1376 }
1377 d = r10_bio->devs[1].devnum; 1378 d = r10_bio->devs[1].devnum;
1378 1379
1379 atomic_inc(&conf->mirrors[d].rdev->nr_pending); 1380 atomic_inc(&conf->mirrors[d].rdev->nr_pending);