From: Jan Kara Date: Tue, 25 Jun 2024 10:18:52 +0000 (+0200) Subject: filemap: fix page_cache_next_miss() when no hole found X-Git-Tag: v6.11-rc1~85^2~162 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=901a269ff3d59c9ee0e6be35c6044dc4bf2c0fdf;p=thirdparty%2Fkernel%2Flinux.git filemap: fix page_cache_next_miss() when no hole found page_cache_next_miss() should return value outside of the specified range when no hole is found. However currently it will return the last index *in* the specified range confusing ondemand_readahead() to think there's a hole in the searched range and upsetting readahead logic. Link: https://lkml.kernel.org/r/20240625101909.12234-2-jack@suse.cz Signed-off-by: Jan Kara Reviewed-by: Josef Bacik Tested-by: Zhang Peng Cc: Matthew Wilcox (Oracle) Signed-off-by: Andrew Morton --- diff --git a/mm/filemap.c b/mm/filemap.c index ea2d44fcd326f..f8858429508be 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1752,12 +1752,12 @@ pgoff_t page_cache_next_miss(struct address_space *mapping, while (max_scan--) { void *entry = xas_next(&xas); if (!entry || xa_is_value(entry)) - break; + return xas.xa_index; if (xas.xa_index == 0) - break; + return 0; } - return xas.xa_index; + return index + max_scan; } EXPORT_SYMBOL(page_cache_next_miss);