diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index cfcbfd5a54679148fdc85d711898bd9768ac8516..50626f4875997932738f7f6a82e34442ada709a4 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -3153,6 +3154,9 @@ int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array) allocated = alloc_pages_bulk_array(GFP_NOFS, nr_pages, page_array); + if (allocated == nr_pages) + return 0; + /* * During this iteration, no page could be allocated, even * though alloc_pages_bulk_array() falls back to alloc_page() @@ -3160,6 +3164,8 @@ int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array) */ if (allocated == last) return -ENOMEM; + + memalloc_retry_wait(GFP_NOFS); } return 0; }