From: sashiko-bot@kernel.org
To: "Christopher Lusk" <clusk@northecho.dev>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH] ext4: do not report interrupted truncate as filesystem error
Date: Sun, 29 Nov 2026 04:54:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-239322@kernel.org> (raw)
In-Reply-To: <20261128-b4-ext4-eintr-v1-1-dc38ab39d1e7@northecho.dev>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] ext4: incomplete truncate-down and orphan corruption in
__ext4_std_error()
- [High] ext4: infinite loop in ext4_orphan_cleanup() on -EINTR in
__ext4_std_error()
--
commit 58e5e8252974ec4aca8d6342e1b1e890589567bb
Author: Christopher Lusk <clusk@northecho.dev>
ext4: do not report interrupted truncate as filesystem error
This commit ignores -EINTR in __ext4_std_error() when a fatal signal is
pending on current.
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 880f664d6c04b..112dfae7a7386 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
[ ... ]
> @@ -1022,6 +1023,9 @@ void __ext4_std_error(struct super_block *sb, const char *function,
> if (errno == -EROFS && journal_current_handle() == NULL && sb_rdonly(sb))
> return;
>
> + if (errno == -EINTR && fatal_signal_pending(current))
> + return;
[Severity: High]
Can ignoring -EINTR here leave a file half-truncated and leak its on-disk
orphan entry when a shrinking truncate is interrupted?
Unlike ext4_truncate_up(), ext4_truncate_down() first commits a transaction
that adds the inode to the on-disk orphan list and shrinks i_size and
i_disksize, and only then calls ext4_truncate(). On buffered_iomap, when
the new size is not block-aligned, ext4_truncate() calls
ext4_block_zero_eof() -> ... -> iomap_write_begin(), which returns -EINTR
if a fatal signal is pending, aborting before freeing blocks past EOF or
removing the on-disk orphan entry:
fs/ext4/inode.c:ext4_truncate_down() {
...
if (ext4_handle_valid(handle)) {
ret = ext4_orphan_add(handle, inode);
*orphan = 1;
...
i_size_write(inode, newsize);
__ext4_set_i_disksize(inode, newsize);
up_write(&EXT4_I(inode)->i_data_sem);
ret = ext4_mark_inode_dirty(handle, inode);
ext4_journal_stop(handle);
...
truncate_pagecache(inode, newsize);
return ext4_truncate(inode);
}
ext4_setattr() then runs ext4_orphan_del(NULL, inode), which clears only
the in-memory orphan state and relies on ext4_std_error() to mark the
filesystem in error. Returning early from __ext4_std_error() leaves the
filesystem read-write with blocks still allocated past i_disksize, an
unzeroed tail block, and a leaked on-disk orphan slot (causing a later
read-only remount or freeze to fail with EFSCORRUPTED in
ext4_mark_recovery_complete()).
[Severity: High]
Could returning early here also cause an infinite loop in
ext4_orphan_cleanup() if the mount or remount task has a fatal signal
pending?
When recovering a linked orphan (inode->i_nlink > 0) with a
non-block-aligned i_size on the superblock orphan list,
ext4_process_orphan() calls ext4_truncate(), which fails with -EINTR in
ext4_block_zero_eof() before updating es->s_last_orphan:
fs/ext4/orphan.c:ext4_process_orphan() {
...
ret = ext4_truncate(inode);
if (ret) {
ext4_orphan_del(NULL, inode);
ext4_std_error(inode->i_sb, ret);
}
...
}
ext4_orphan_del(NULL, inode) only unlinks the in-memory list entry, and
the while (es->s_last_orphan) loop in ext4_orphan_cleanup() relies on
EXT4_ERROR_FS being set by ext4_std_error() to break out. Without
EXT4_ERROR_FS, es->s_last_orphan never advances and the loop spins
forever on the same inode.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128-b4-ext4-eintr-v1-1-dc38ab39d1e7@northecho.dev?part=1
next prev parent reply other threads:[~2026-11-29 4:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 4:37 [PATCH] ext4: do not report interrupted truncate as filesystem error Christopher Lusk
2026-11-29 4:37 ` Christopher Lusk via B4 Relay
2026-11-29 4:54 ` sashiko-bot [this message]
2026-11-29 13:48 ` Christopher Lusk
2026-11-29 14:37 ` Christopher Lusk
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=sashiko-outbox-239322@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clusk@northecho.dev \
--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.