diff options
author | Kent Overstreet <koverstreet@google.com> | 2012-09-10 14:03:28 -0700 |
---|---|---|
committer | Kent Overstreet <koverstreet@google.com> | 2013-03-23 14:26:31 -0700 |
commit | a07876064a0b73ab5ef1ebcf14b1cf0231c07858 (patch) | |
tree | 74a0567401bcdb60f5a8e65c76d5a3a21aeb548f /drivers/md | |
parent | cb34e057ad22a1c2c6f2cb6cd1cbd05cc2f28f28 (diff) | |
download | op-kernel-dev-a07876064a0b73ab5ef1ebcf14b1cf0231c07858.zip op-kernel-dev-a07876064a0b73ab5ef1ebcf14b1cf0231c07858.tar.gz |
block: Add bio_alloc_pages()
More utility code to replace stuff that's getting open coded.
Signed-off-by: Kent Overstreet <koverstreet@google.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/raid1.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index a7ea954..aeb4e3f 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -92,7 +92,6 @@ static void r1bio_pool_free(void *r1_bio, void *data) static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) { struct pool_info *pi = data; - struct page *page; struct r1bio *r1_bio; struct bio *bio; int i, j; @@ -122,14 +121,10 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) j = 1; while(j--) { bio = r1_bio->bios[j]; - for (i = 0; i < RESYNC_PAGES; i++) { - page = alloc_page(gfp_flags); - if (unlikely(!page)) - goto out_free_pages; + bio->bi_vcnt = RESYNC_PAGES; - bio->bi_io_vec[i].bv_page = page; - bio->bi_vcnt = i+1; - } + if (bio_alloc_pages(bio, gfp_flags)) + goto out_free_bio; } /* If not user-requests, copy the page pointers to all bios */ if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) { @@ -143,11 +138,6 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) return r1_bio; -out_free_pages: - for (j=0 ; j < pi->raid_disks; j++) - for (i=0; i < r1_bio->bios[j]->bi_vcnt ; i++) - put_page(r1_bio->bios[j]->bi_io_vec[i].bv_page); - j = -1; out_free_bio: while (++j < pi->raid_disks) bio_put(r1_bio->bios[j]); |