Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH v4 0/2] ext4: punch hole beyond i_size
@ 2026-12-03 14:15 Ding Feng
  2026-12-03 14:15 ` [PATCH v4 1/2] ext4: fix the fast commit range of a punched hole Ding Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ding Feng @ 2026-12-03 14:15 UTC (permalink / raw)
  To: tytso, adilger.kernel
  Cc: jack, libaokun, ojaswin, ritesh.list, yi.zhang, hughd, david,
	linux-ext4, linux-kernel

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 v3 [1]:

- Patch 2: call ext4_update_disksize_before_punch() only for a hole that
  starts below i_size (Sashiko [2]). Since v1, a punch at i_size moved
  i_disksize up to i_size ahead of writeback: after a buffered 1 MiB
  append, a punch at 1 MiB and a journal-only shutdown, v3 brought the
  file back as 1 MiB of zeros; v4, like v7.4-rc5, brings it back empty.
- Patch 1: leave ext4_fc_track_inode() where it was. v2 and v3 moved it
  out of "if (end_lblk > start_lblk)" so that a hole within one block
  would still queue the inode, but ext4_mark_inode_dirty() queues it on
  every path, so the move changed nothing.
- Patch 2: the changelog and a comment said that nothing past EOF is
  written and that the EOF block is freed. A hole that starts inside
  the EOF block zeroes it to its end and keeps it, as before; both now
  say so. The KUnit case "Punch past i_size is a no-op" is reworded to
  what it checks.

Changes since v2 [3]: patch 2 keeps rounding a hole that reaches i_size
up to the end of the EOF block, so the EOF block is still freed.

Changes since v1 [4]: patch 1 is new; with v1 on a fast_commit
filesystem, punching [0, s_maxbytes), fsync and a shutdown brought the
punched data back after replay. Patch 2 zeroes nothing for a hole that
starts past i_size and cites Fixes: 2be4751b21ae.

Tested on v7.4-rc5, x86_64 under QEMU:

- fstests -g punch on ext4 with 4k and 1k blocks: generic/042 fails with
  and without the series, nothing else fails. On ext4 without extents
  the 8 punch tests that run without falloc pass.
- generic/811, "generic: punch a hole past EOF over preallocated
  blocks" [5], fails without the series and passes with it, on ext4 4k
  and 1k; it passes on XFS.
- ext4 KUnit: 538 pass. W=1 adds no warnings.
- The i_disksize and fast commit crash checks above, a 5000-byte file
  punched over [0, 5000) and [0, 6000) at 4k and 1k blocks (the EOF
  block is freed), and punches past EOF on indirect-block files
  (e2fsck clean).
- Not tested: bigalloc, block sizes above 4k, DAX.

[1] https://lore.kernel.org/all/20261203130608.64892-1-dingf3ng@gmail.com/
[2] https://lore.kernel.org/all/sashiko-outbox-247862@kernel.org/
[3] https://lore.kernel.org/all/20261203115201.48810-1-dingf3ng@gmail.com/
[4] https://lore.kernel.org/all/20261203091435.73786-1-dingf3ng@gmail.com/
[5] https://lore.kernel.org/all/20261203115229.50163-1-dingf3ng@gmail.com/

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

 fs/ext4/inode-test.c |  2 +-
 fs/ext4/inode.c      | 35 ++++++++++++++++++++++-------------
 2 files changed, 23 insertions(+), 14 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-03 15:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 14:15 [PATCH v4 0/2] ext4: punch hole beyond i_size Ding Feng
2026-12-03 14:15 ` [PATCH v4 1/2] ext4: fix the fast commit range of a punched hole Ding Feng
2026-12-03 14:15 ` [PATCH v4 2/2] ext4: punch hole beyond i_size Ding Feng
2026-12-03 15:07 ` [PATCH v4 0/2] " sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox