From: sashiko-bot@kernel.org
To: "Ding Feng" <dingf3ng@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH v3 2/2] ext4: punch hole beyond i_size
Date: Thu, 03 Dec 2026 13:32:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-247862@kernel.org> (raw)
In-Reply-To: <20261203130608.64892-3-dingf3ng@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ext4: ext4_punch_hole() advances i_disksize on punch at
offset == i_size
--
commit 2e70b22512cf9036462d361406187d89e988b04d
Author: Ding Feng <dingf3ng@gmail.com>
ext4: punch hole beyond i_size
This commit updates ext4_punch_hole() to remove extents beyond i_size instead
of returning early or stopping at the block holding i_size, while limiting
partial-block zeroing to ranges starting below i_size.
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 26cf00ff8630a..f7d0a2e9941cb 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
[ ... ]
> @@ -5371,19 +5372,22 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
> if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> max_end = EXT4_SB(sb)->s_bitmap_maxbytes - sb->s_blocksize;
>
> - /* No need to punch hole beyond i_size */
> - if (offset >= inode->i_size || offset >= max_end)
> + if (offset >= max_end)
> return 0;
> -
> /*
> - * If the hole extends beyond i_size, set the hole to end after
> - * the block that contains i_size to save pointless tail block zeroing.
> + * A hole that reaches i_size covers the rest of the block that holds
> + * i_size, so that block is freed rather than zeroed.
> */
> if (end >= inode->i_size)
> - end = round_up(inode->i_size, sb->s_blocksize);
> + end = max_t(loff_t, end, round_up(inode->i_size, sb->s_blocksize));
> if (end > max_end)
> end = max_end;
> length = end - offset;
> + /*
> + * Blocks past i_size (from FALLOC_FL_KEEP_SIZE) are removed too, but
> + * nothing after the block that contains i_size needs zeroing.
> + */
> + zero_end = min_t(loff_t, end, round_up(inode->i_size, sb->s_blocksize));
>
> ret = ext4_update_disksize_before_punch(inode, offset, length);
> if (ret)
[Severity: Medium]
Can ext4_update_disksize_before_punch() now advance i_disksize when a hole
starts at offset == i_size?
After an appending buffered delalloc write, i_disksize lags behind i_size
until writeback. Because ext4_update_disksize_before_punch() only returns
early for offset > size, a punch at offset == i_size falls through, starts
a journal transaction, and advances i_disksize to i_size.
If the journal commits and the system crashes before writeback flushes the
dirty pages below i_size, crash recovery exposes a file of size i_size filled
with zero bytes instead of the prior on-disk size. Guarding the call with
offset < inode->i_size (or checking offset >= size in the helper) avoids this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203130608.64892-1-dingf3ng@gmail.com?part=2
next prev parent reply other threads:[~2026-12-03 13:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 13:06 [PATCH v3 0/2] ext4: punch hole beyond i_size Ding Feng
2026-12-03 13:06 ` [PATCH v3 1/2] ext4: fix the fast commit range of a punched hole Ding Feng
2026-12-03 13:06 ` [PATCH v3 2/2] ext4: punch hole beyond i_size Ding Feng
2026-12-03 13:32 ` sashiko-bot [this message]
2026-12-03 13:32 ` [PATCH v3 0/2] " sashiko-bot
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-247862@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dingf3ng@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox