Skip to content

Commit

Permalink
mm/filemap.c: remove redundant test from find_get_pages_contig
Browse files Browse the repository at this point in the history
After we establish a reference on the page, we check the pointer
continues to be in the correct position in i_pages.  Checking
page->index afterwards is unnecessary; if it were to change, then the
pointer to it from the page cache would also move.  The check used to be
done before grabbing a reference on the page which was racy (see commit
9cbb4cb ("mm: find_get_pages_contig fixlet")), but nobody noticed
that moving the check after grabbing the reference was redundant.

Link: http://lkml.kernel.org/r/20190107200224.13260-1-willy@infradead.org
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Matthew Wilcox authored and Linus Torvalds committed Mar 6, 2019
1 parent 67b8046 commit 14ef1fc
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1837,16 +1837,6 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
if (unlikely(page != xas_reload(&xas)))
goto put_page;

/*
* must check mapping and index after taking the ref.
* otherwise we can get both false positives and false
* negatives, which is just confusing to the caller.
*/
if (!page->mapping || page_to_pgoff(page) != xas.xa_index) {
put_page(page);
break;
}

pages[ret] = page;
if (++ret == nr_pages)
break;
Expand Down

0 comments on commit 14ef1fc

Please sign in to comment.