mm: allow GFP_{FS,IO} for page_cache_read page cache allocation
[cascardo/linux.git] / mm / filemap.c
index 1bb0076..ff42d31 100644 (file)
@@ -1812,19 +1812,18 @@ EXPORT_SYMBOL(generic_file_read_iter);
  * This adds the requested page to the page cache if it isn't already there,
  * and schedules an I/O to read in its contents from disk.
  */
-static int page_cache_read(struct file *file, pgoff_t offset)
+static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask)
 {
        struct address_space *mapping = file->f_mapping;
        struct page *page;
        int ret;
 
        do {
-               page = page_cache_alloc_cold(mapping);
+               page = __page_cache_alloc(gfp_mask|__GFP_COLD);
                if (!page)
                        return -ENOMEM;
 
-               ret = add_to_page_cache_lru(page, mapping, offset,
-                               mapping_gfp_constraint(mapping, GFP_KERNEL));
+               ret = add_to_page_cache_lru(page, mapping, offset, gfp_mask & GFP_KERNEL);
                if (ret == 0)
                        ret = mapping->a_ops->readpage(file, page);
                else if (ret == -EEXIST)
@@ -2005,7 +2004,7 @@ no_cached_page:
         * We're only likely to ever get here if MADV_RANDOM is in
         * effect.
         */
-       error = page_cache_read(file, offset);
+       error = page_cache_read(file, offset, vmf->gfp_mask);
 
        /*
         * The page we want has now been added to the page cache.