thp: consolidate code between handle_mm_fault() and do_huge_pmd_anonymous_page()
[firefly-linux-kernel-4.4.55.git] / mm / readahead.c
index daed28dd583031b4759f68b04cfb7e99c0f60d48..e4ed04149785f069b201cd2ffaa9caa90c4b0d22 100644 (file)
@@ -48,7 +48,7 @@ static void read_cache_pages_invalidate_page(struct address_space *mapping,
                if (!trylock_page(page))
                        BUG();
                page->mapping = mapping;
-               do_invalidatepage(page, 0);
+               do_invalidatepage(page, 0, PAGE_CACHE_SIZE);
                page->mapping = NULL;
                unlock_page(page);
        }
@@ -371,10 +371,10 @@ static int try_context_readahead(struct address_space *mapping,
        size = count_history_pages(mapping, ra, offset, max);
 
        /*
-        * no history pages:
+        * not enough history pages:
         * it could be a random read
         */
-       if (!size)
+       if (size <= req_size)
                return 0;
 
        /*
@@ -385,8 +385,8 @@ static int try_context_readahead(struct address_space *mapping,
                size *= 2;
 
        ra->start = offset;
-       ra->size = get_init_ra_size(size + req_size, max);
-       ra->async_size = ra->size;
+       ra->size = min(size + req_size, max);
+       ra->async_size = 1;
 
        return 1;
 }