From: Jan Kara <jack@suse.cz>
To: Chi Zhiling <chizhiling@163.com>
Cc: willy@infradead.org, akpm@linux-foundation.org,
josef@toxicpanda.com, jack@suse.cz,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Chi Zhiling <chizhiling@kylinos.cn>
Subject: Re: [PATCH] readahead: fix return value of page_cache_next_miss() when no hole is found
Date: Thu, 5 Jun 2025 10:22:23 +0200 [thread overview]
Message-ID: <qbuhdfdvbyida5y7g34o4rf5s5ntx462ffy3wso3pb5f3t4pev@3hqnswkp7of6> (raw)
In-Reply-To: <20250605054935.2323451-1-chizhiling@163.com>
On Thu 05-06-25 13:49:35, Chi Zhiling wrote:
> From: Chi Zhiling <chizhiling@kylinos.cn>
>
> max_scan in page_cache_next_miss always decreases to zero when no hole
> is found, causing the return value to be index + 0.
>
> Fix this by preserving the max_scan value throughout the loop.
>
> Fixes: 901a269ff3d5 ("filemap: fix page_cache_next_miss() when no hole found")
> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Indeed. Thanks for catching this. Don't know how I missed that. Feel free
to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> mm/filemap.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index b5e784f34d98..148be65be1cd 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -1767,8 +1767,9 @@ pgoff_t page_cache_next_miss(struct address_space *mapping,
> pgoff_t index, unsigned long max_scan)
> {
> XA_STATE(xas, &mapping->i_pages, index);
> + unsigned long nr = max_scan;
>
> - while (max_scan--) {
> + while (nr--) {
> void *entry = xas_next(&xas);
> if (!entry || xa_is_value(entry))
> return xas.xa_index;
> --
> 2.43.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2025-06-05 8:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-05 5:49 Chi Zhiling
2025-06-05 8:22 ` Jan Kara [this message]
2025-06-05 21:51 ` Andrew Morton
2025-06-06 10:54 ` Jan Kara
2025-06-08 3:00 ` Chi Zhiling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=qbuhdfdvbyida5y7g34o4rf5s5ntx462ffy3wso3pb5f3t4pev@3hqnswkp7of6 \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=chizhiling@163.com \
--cc=chizhiling@kylinos.cn \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox