All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "shuo chen" <1289151713@qq.com>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v2] ext4:Fix WARNING in ext4_journalled_invalidate_folio
Date: Mon, 14 Sep 2026 17:07:32 +0000	[thread overview]
Message-ID: <20260914170733.20DFA1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <tencent_87F5A404ED65B0B1349C60E830C485716705@qq.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The WARNING in ext4_journalled_invalidate_folio can still be triggered from ext4_write_begin on error paths.
--

commit 83d8cc4138093c0b6b19db042eb3a85e72ca5b68
Author: shuo chen <1289151713@qq.com>

    ext4:Fix WARNING in ext4_journalled_invalidate_folio

This commit fixes a warning in ext4_journalled_invalidate_folio() by
calling ext4_wait_for_tail_page_commit() before truncating a failed write
in ext4_journalled_write_end(). This prevents invalidating the folio while
it is being committed.

Suggested-by: Jan Kara <jack@suse.cz>
Reported-by: Farhad Alemi <farhad.alemi@berkeley.edu>
Closes:https://lore.kernel.org/linux-ext4/CA+0ovCgxFN3TLpdS_O_Z48sARuQ-WR-JLDCqQWEmd9ELtkzddA@mail.gmail.com/T/
Signed-off-by: shuo chen <1289151713@qq.com>

> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 26f0f9714f03c..960a049a67bd2 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c

[ ... ]

> @@ -1597,6 +1598,7 @@ static int ext4_journalled_write_end(const struct kiocb *iocb,
>  	if (!ret)
>  		ret = ret2;
>  	if (pos + len > inode->i_size && !verity) {
> +		ext4_wait_for_tail_page_commit(inode);
>  		ext4_truncate_failed_write(inode);
>  		/*
>  		 * If truncate failed early the inode might still be

[Severity: High]
This isn't a bug introduced by this patch, but it appears the same issue
might still exist on the error paths in ext4_write_begin().

When a write fails (e.g., due to ENOSPC or block allocation failure) and
extends i_size on a data=journal file, does ext4_write_begin() also need
to wait for the tail page commit?

fs/ext4/inode.c:ext4_write_begin() {
	...
		ext4_journal_stop(handle);
		if (extended) {
			ext4_truncate_failed_write(inode);
	...
}

If ext4_truncate_failed_write() attempts to invalidate the folio without
waiting, jbd2_journal_invalidate_folio() could return -EBUSY because the
buffer is still committing. Could this leave the page cache in an
inconsistent state and trigger the WARN_ON in
ext4_journalled_invalidate_folio()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_87F5A404ED65B0B1349C60E830C485716705@qq.com?part=1

  reply	other threads:[~2026-09-14 17:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  2:19 [PATCH] ext4:Fix WARNING in ext4_journalled_invalidate_folio shuo chen
2026-09-14  2:38 ` sashiko-bot
2026-09-14 10:13 ` Jan Kara
2026-09-14 16:41 ` [PATCH v2] " shuo chen
2026-09-14 17:07   ` sashiko-bot [this message]
2026-09-14 18:47   ` Jan Kara

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=20260914170733.20DFA1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=1289151713@qq.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    /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.