diff options
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r-- | fs/btrfs/extent_io.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 97efc2f22597..3e7c9ed6505b 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -3566,19 +3566,38 @@ int extent_readpages(struct extent_io_tree *tree, | |||
3566 | struct bio *bio = NULL; | 3566 | struct bio *bio = NULL; |
3567 | unsigned page_idx; | 3567 | unsigned page_idx; |
3568 | unsigned long bio_flags = 0; | 3568 | unsigned long bio_flags = 0; |
3569 | struct page *pagepool[16]; | ||
3570 | struct page *page; | ||
3571 | int i = 0; | ||
3572 | int nr = 0; | ||
3569 | 3573 | ||
3570 | for (page_idx = 0; page_idx < nr_pages; page_idx++) { | 3574 | for (page_idx = 0; page_idx < nr_pages; page_idx++) { |
3571 | struct page *page = list_entry(pages->prev, struct page, lru); | 3575 | page = list_entry(pages->prev, struct page, lru); |
3572 | 3576 | ||
3573 | prefetchw(&page->flags); | 3577 | prefetchw(&page->flags); |
3574 | list_del(&page->lru); | 3578 | list_del(&page->lru); |
3575 | if (!add_to_page_cache_lru(page, mapping, | 3579 | if (add_to_page_cache_lru(page, mapping, |
3576 | page->index, GFP_NOFS)) { | 3580 | page->index, GFP_NOFS)) { |
3577 | __extent_read_full_page(tree, page, get_extent, | 3581 | page_cache_release(page); |
3578 | &bio, 0, &bio_flags); | 3582 | continue; |
3579 | } | 3583 | } |
3580 | page_cache_release(page); | 3584 | |
3585 | pagepool[nr++] = page; | ||
3586 | if (nr < ARRAY_SIZE(pagepool)) | ||
3587 | continue; | ||
3588 | for (i = 0; i < nr; i++) { | ||
3589 | __extent_read_full_page(tree, pagepool[i], get_extent, | ||
3590 | &bio, 0, &bio_flags); | ||
3591 | page_cache_release(pagepool[i]); | ||
3592 | } | ||
3593 | nr = 0; | ||
3581 | } | 3594 | } |
3595 | for (i = 0; i < nr; i++) { | ||
3596 | __extent_read_full_page(tree, pagepool[i], get_extent, | ||
3597 | &bio, 0, &bio_flags); | ||
3598 | page_cache_release(pagepool[i]); | ||
3599 | } | ||
3600 | |||
3582 | BUG_ON(!list_empty(pages)); | 3601 | BUG_ON(!list_empty(pages)); |
3583 | if (bio) | 3602 | if (bio) |
3584 | return submit_one_bio(READ, bio, 0, bio_flags); | 3603 | return submit_one_bio(READ, bio, 0, bio_flags); |