aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid1.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r--drivers/md/raid1.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4a6ca1cb2e78..56e24c072b62 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -97,6 +97,7 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
97 struct pool_info *pi = data; 97 struct pool_info *pi = data;
98 struct r1bio *r1_bio; 98 struct r1bio *r1_bio;
99 struct bio *bio; 99 struct bio *bio;
100 int need_pages;
100 int i, j; 101 int i, j;
101 102
102 r1_bio = r1bio_pool_alloc(gfp_flags, pi); 103 r1_bio = r1bio_pool_alloc(gfp_flags, pi);
@@ -119,15 +120,15 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
119 * RESYNC_PAGES for each bio. 120 * RESYNC_PAGES for each bio.
120 */ 121 */
121 if (test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) 122 if (test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery))
122 j = pi->raid_disks; 123 need_pages = pi->raid_disks;
123 else 124 else
124 j = 1; 125 need_pages = 1;
125 while(j--) { 126 for (j = 0; j < need_pages; j++) {
126 bio = r1_bio->bios[j]; 127 bio = r1_bio->bios[j];
127 bio->bi_vcnt = RESYNC_PAGES; 128 bio->bi_vcnt = RESYNC_PAGES;
128 129
129 if (bio_alloc_pages(bio, gfp_flags)) 130 if (bio_alloc_pages(bio, gfp_flags))
130 goto out_free_bio; 131 goto out_free_pages;
131 } 132 }
132 /* If not user-requests, copy the page pointers to all bios */ 133 /* If not user-requests, copy the page pointers to all bios */
133 if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) { 134 if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) {
@@ -141,6 +142,14 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
141 142
142 return r1_bio; 143 return r1_bio;
143 144
145out_free_pages:
146 while (--j >= 0) {
147 struct bio_vec *bv;
148
149 bio_for_each_segment_all(bv, r1_bio->bios[j], i)
150 __free_page(bv->bv_page);
151 }
152
144out_free_bio: 153out_free_bio:
145 while (++j < pi->raid_disks) 154 while (++j < pi->raid_disks)
146 bio_put(r1_bio->bios[j]); 155 bio_put(r1_bio->bios[j]);