[PATCH 0/1] fix page_cache_next/prev_miss off by one error

From: Mike Kravetz
Date: Thu May 04 2023 - 19:39:48 EST


A cover letter is not necessary for this single patch as all information
is present in the commit message. However, I am not 100% comfortable in
this change and would REALLY like to get comments from Matthew.

When reporting this issue, Ackerley Tng suggested a solution by creating
a new filemap_has_folio() function[1]. I believe that would be an
acceptable way to proceed although we would also need to change the
other use of page_cache_next_miss in hugetlb.c.

When looking more closely, it looks like page_cache_next/prev_miss do
not work exactly as described. The result is the following patch.

IIUC, prior to hugetlb use of page_cache_next/prev_miss, it was only
used by readahead code. My patch does change the return value and has
potential to impact the readahead users. That is why I am not 100%
comfortable with this.

In any case, this is broken in v6.3 so we need a fix.

[1] https://lore.kernel.org/linux-mm/cover.1683069252.git.ackerleytng@xxxxxxxxxx/
Mike Kravetz (1):
page cache: fix page_cache_next/prev_miss off by one

mm/filemap.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)

--
2.40.0