diff --git a/mm/filemap.c b/mm/filemap.c index a29318147365..f807afda86f2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -885,6 +885,13 @@ unsigned find_get_pages(struct address_space *mapping, pgoff_t start, pages[ret] = page; ret++; } + + /* + * If all entries were removed before we could secure them, + * try again, because callers stop trying once 0 is returned. + */ + if (unlikely(!ret && nr_found)) + goto restart; rcu_read_unlock(); return ret; } @@ -1004,6 +1011,13 @@ unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index, pages[ret] = page; ret++; } + + /* + * If all entries were removed before we could secure them, + * try again, because callers stop trying once 0 is returned. + */ + if (unlikely(!ret && nr_found)) + goto restart; rcu_read_unlock(); if (ret)