All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhang Yi" <yi.zhang@huaweicloud.com>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v4 4/4] mm/truncate: clarify return value of truncate_inode_partial_folio()
Date: Tue, 22 Sep 2026 11:29:40 +0000	[thread overview]
Message-ID: <20260922112940.BEF871F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922110703.468389-5-yi.zhang@huaweicloud.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mm: newly split large folios are skipped during shmem truncation
--

commit 15553d4635c639eef475fb728e2da88b1d36fe93
Author: Zhang Yi <yi.zhang@huawei.com>

mm/truncate: clarify return value of truncate_inode_partial_folio()

This commit clarifies the return value of truncate_inode_partial_folio()
to strictly indicate whether at least one split succeeded. The callers now
use this return value as a flag to determine whether the truncation loop
should be reset to pick up newly split sub-folios on the shmem path.

> diff --git a/mm/truncate.c b/mm/truncate.c
> index 81fb4de6226bc..317cb4ae36259 100644
> --- a/mm/truncate.c
> +++ b/mm/truncate.c
> @@ -216,8 +216,7 @@ static int folio_split_or_unmap(struct folio *folio, struct page *split_at,
>   * aligned inwards to min_order, i.e. the range of folios wholly within
>   * [lstart, lend] and so safe to discard.
>   *
> - * Returns false if splitting failed so the caller can avoid
> - * discarding the entire folio which is stubbornly unsplit.
> + * Return %true if at least one split succeeded, %false otherwise.
>   */
>  bool truncate_inode_partial_folio(struct folio *folio, loff_t lstart,
>  				  loff_t lend, pgoff_t *pstart, pgoff_t *pend)

[Severity: High]
Does shmem_undo_range() still rely on an outdated check instead of just this
return value?

mm/shmem.c:shmem_undo_range() {
    ...
				} else if (truncate_inode_partial_folio(folio,
						lstart, lend, NULL, NULL)) {
					if (!folio_test_large(folio)) {
						folio_unlock(folio);
						index = start;
						break;
					}
				}
    ...
}

Because folio_split() can perform non-uniform splits, the resulting sub-folio
could still be a large folio (order > 0). If it is, folio_test_large(folio)
evaluates to true, so this check prevents the loop from resetting even when
truncate_inode_partial_folio() successfully split it.

Since find_get_entries() has already advanced the search index, the loop
continues from the advanced index and bypasses the newly split sub-folios
within the truncation range.

Can this cause newly split sub-folios to be skipped, leaving them in the page
cache beyond EOF?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260922110703.468389-1-yi.zhang@huaweicloud.com?part=4

  reply	other threads:[~2026-09-22 11:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 11:06 [PATCH v4 0/4] mm/truncate: fix data loss when truncating straddling large folios Zhang Yi
2026-09-22 11:07 ` [PATCH v4 1/4] mm/truncate: align truncation boundaries to mapping minimum folio order Zhang Yi
2026-09-22 11:27   ` sashiko-bot
2026-09-22 11:32   ` Jan Kara
2026-09-22 15:29   ` Zi Yan
2026-09-23  8:26     ` Zhang Yi
2026-09-24  9:31   ` Zhang Yi
2026-09-24 10:31     ` Jan Kara
2026-09-22 11:07 ` [PATCH v4 2/4] mm/truncate: look up the end-edge straddler by index Zhang Yi
2026-09-22 11:23   ` sashiko-bot
2026-09-22 11:35   ` Jan Kara
2026-09-22 15:30   ` Zi Yan
2026-09-22 11:07 ` [PATCH v4 3/4] mm/truncate: fix data loss when splitting straddling large folios fails Zhang Yi
2026-09-22 11:23   ` sashiko-bot
2026-09-22 11:44   ` Jan Kara
2026-09-22 16:58   ` Zi Yan
2026-09-22 17:27   ` Zi Yan
2026-09-23  8:29     ` Zhang Yi
2026-09-22 11:07 ` [PATCH v4 4/4] mm/truncate: clarify return value of truncate_inode_partial_folio() Zhang Yi
2026-09-22 11:29   ` sashiko-bot [this message]
2026-09-22 11:58   ` Jan Kara
2026-09-23 13:29     ` Zhang Yi
2026-09-22 17:28   ` Zi Yan
2026-09-22 13:47 ` [PATCH v4 0/4] mm/truncate: fix data loss when truncating straddling large folios Brian Foster
2026-09-23 13:31   ` Zhang Yi

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=20260922112940.BEF871F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    --cc=yi.zhang@huaweicloud.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.