Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Ding Feng <dingf3ng@gmail.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca
Cc: jack@suse.cz, libaokun@linux.alibaba.com, ojaswin@linux.ibm.com,
	ritesh.list@gmail.com, yi.zhang@huawei.com, hughd@google.com,
	david@fromorbit.com, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/2] ext4: punch hole beyond i_size
Date: Thu,  3 Dec 2026 19:51:59 +0800	[thread overview]
Message-ID: <20261203115201.48810-1-dingf3ng@gmail.com> (raw)

ext4 cannot punch out blocks that FALLOC_FL_KEEP_SIZE allocated past
EOF: ext4_punch_hole() returns early for a hole that starts at or past
i_size, and ends any other hole at the block that holds i_size. Patch 2
lifts that limit. Patch 1 fixes the range the punch records for fast
commit, which wraps to 0 once a hole can run to s_maxbytes.

Changes since v1 [1], from the Sashiko review [2]:

- New patch 1. With v1 on a fast_commit filesystem, punching
  [0, s_maxbytes) over a 1 MiB file, then fsync and a shutdown, brought
  the punched data back after replay (st_blocks 2048, the old bytes);
  with v2 the blocks stay freed. The review suggested moving
  ext4_fc_track_range() under "if (end_lblk > start_lblk)"; patch 1
  also moves ext4_fc_track_inode() out of it, so that a hole within one
  block still queues the inode, as the old call at the end did.
- Patch 2: zero partial blocks only for a hole that starts below i_size,
  so a hole that starts in the tail of the EOF block writes nothing.
- Patch 2: Fixes: 2be4751b21ae, which added the i_size checks, instead
  of a4bb6b64e39a.

Tested on v7.4-rc5, x86_64 under QEMU, ext4 with 4k blocks:

- fstests -g punch: 24 run, 27 not run; generic/042 fails with and
  without the series, nothing else fails.
- "generic: punch a hole past EOF over preallocated blocks" (v2 sent to
  fstests) fails without the series and passes with it; it passes on
  XFS.
- The fast commit crash check above passes on v7.4-rc5 and with v2.

[1] https://lore.kernel.org/all/20261203091435.73786-1-dingf3ng@gmail.com/
[2] https://lore.kernel.org/all/sashiko-outbox-247494@kernel.org/

Ding Feng (2):
  ext4: fix the fast commit range of a punched hole
  ext4: punch hole beyond i_size

 fs/ext4/inode.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

-- 
2.39.5

             reply	other threads:[~2026-12-03 11:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 11:51 Ding Feng [this message]
2026-12-03 11:52 ` [PATCH v2 1/2] ext4: fix the fast commit range of a punched hole Ding Feng
2026-12-03 11:52 ` [PATCH v2 2/2] ext4: punch hole beyond i_size Ding Feng

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=20261203115201.48810-1-dingf3ng@gmail.com \
    --to=dingf3ng@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=david@fromorbit.com \
    --cc=hughd@google.com \
    --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@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox