From: Zhang Yi <yizhang089@gmail.com>
To: Theodore Tso <tytso@mit.edu>, Zhang Yi <yi.zhang@huaweicloud.com>
Cc: Jan Kara <jack@suse.cz>, Guanghui Yang <3497809730@qq.com>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Baokun Li <libaokun@linux.alibaba.com>,
Ojaswin Mujoo <ojaswin@linux.ibm.com>,
Ritesh Harjani <ritesh.list@gmail.com>,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] ext4: orphan tracking after a failed truncate
Date: Thu, 20 Aug 2026 23:18:59 +0800 [thread overview]
Message-ID: <daa118a5-1efb-49dd-9038-49d0c0b351fc@gmail.com> (raw)
In-Reply-To: <aoRhIeFzNqHg34jg@mit.edu>
On 8/18/2026 9:48 PM, Theodore Tso wrote:
> On Tue, Aug 18, 2026 at 12:41:57PM -0500, Zhang Yi wrote:
>> I think we might want to add a small qualifier here: this is only expected
>> behavior under errors=continue. For the remount-ro case, we immediately
>> abort the journal to prevent writing out inconsistent metadata after an I/O
>> error, which helps contain the damage. So after journal replay, the file
>> system should still be able to maintain a consistent state.
>
> Errors={continue,remount-ro,panic} only apply if the ext4_error()
> family is called. The problem is that ext4_ext_remove_space(), which
> is called by ext4_ext_truncate() calls read_extent_tree_block() and if
> it returns an error, it returns EIO without actually calling
> ext4_error(). So the truncate system call will return EIO, with
> i_size set to zero, but with blocks beyond EOF still left allocated.
>
I checked the code. Apart from the verity path, all callers
of ext4_truncate() already call ext4_handle_error() when it returns
an error. So it doesn't look like there's any issue with truncate
at the moment. So I suspect that Guanghui won't be able to reproduce
this issue in remount-ro mode, and I'd suggest that similar consistency
tests under fault injection scenarios should all be run in remount-ro
mode.
> As I menstioned, that's not _fatal_ in that case, since blocks beyond
> EOF can happen with fallocate(2) with FALLOC_FL_KEEP_SIZE. But it
> could be a bit surprising, since truncate return an error, but the
> file was actually apparently truncated (or partially truncated, in any
> case).
>
It seems we can't guarantee that the file being truncated is always
preallocated. If the blocks were already in written state, then after
we update i_disksize to 0 but there are still blocks left unreleased,
fsck will still complain, Did I get this right?
Best Regards
Yi.
> We could change it to call ext4_error() which would signal the system
> administrator would get a clear signal that she should run fsck, but
> in terms of bugs, it's not as serious as if the file system was left
> actually corrupted.
>
> Cheers,
>
> - Ted
>
prev parent reply other threads:[~2026-08-20 15:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 5:45 [RFC] ext4: orphan tracking after a failed truncate Guanghui Yang
2026-08-17 15:56 ` Jan Kara
2026-08-18 3:04 ` Theodore Tso
2026-08-18 4:41 ` Zhang Yi
2026-08-18 13:48 ` Theodore Tso
2026-08-20 15:18 ` Zhang Yi [this message]
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=daa118a5-1efb-49dd-9038-49d0c0b351fc@gmail.com \
--to=yizhang089@gmail.com \
--cc=3497809730@qq.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=libaokun@linux.alibaba.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--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.