Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH v3 0/2] ext4: fix fast commit orphan inode replay and truncate range tracking
@ 2026-11-30 23:05 Xing Ma
  2026-11-30 23:05 ` [PATCH v3 1/2] ext4: fall back to full commit for unlinked or orphan inodes in fast commit Xing Ma
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Xing Ma @ 2026-11-30 23:05 UTC (permalink / raw)
  To: linux-ext4
  Cc: Theodore Ts'o, Andreas Dilger, Jan Kara, Baokun Li,
	Ojaswin Mujoo, Ritesh Harjani (IBM), Zhang Yi, Harshad Shirwadkar

This 2-patch series fixes two crash-recovery bugs in ext4 fast commit
on tytso/ext4.git dev (aceadbccd428f):

1. Patch 1 ("ext4: fall back to full commit for unlinked or orphan
   inodes in fast commit"):
   Fast commit does not log orphan list updates.  Snapshotting an
   unlinked open inode (i_nlink == 0) emits EXT4_FC_TAG_INODE with
   i_links_count == 0, which causes ext4_fc_replay_inode() to fail
   ext4_iget() with -ESTALE -> -EFSCORRUPTED and abort journal recovery.
   Snapshotting a mid-truncate orphan inode logs shrunk i_size with
   unfreed extents.  Fall back cleanly to a full JBD2 commit via
   -ECANCELED, and add KUnit coverage in fast_commit-test.c.

2. Patch 2 ("ext4: track truncated block range in ext4_truncate() for
   fast commit"):
   ext4_fc_track_range() for truncation is only called in
   ext4_truncate_down(), missing same-size ftruncate(fd, oldsize)
   dropping FALLOC_FL_KEEP_SIZE post-EOF blocks, cross-transaction
   ext4_truncate() handles, and handle restarts in
   ext4_ext_remove_space() / ext4_ind_truncate().  Insert an
   EXTENT_STATUS_HOLE entry for [last_block, EXT_MAX_BLOCKS - 1] in
   ext4_ext_truncate() (when fast commit is enabled and the inode is
   still linked) and call ext4_fc_track_range() in ext4_truncate().

Changes since v2 (addressing Sashiko AI review):
- Patch 1: unchanged (no issues found).
- Patch 2:
  * In ext4_ext_truncate(), insert EXTENT_STATUS_HOLE covering
    [last_block, EXT_MAX_BLOCKS - 1] after ext4_ext_remove_space()
    succeeds (when JOURNAL_FAST_COMMIT is enabled and i_nlink != 0),
    matching ext4_punch_hole().  Without this hole entry,
    ext4_fc_snapshot_inode_data() hits EXT4_FC_SNAP_ERR_ES_MISS and
    falls back to a full commit (even on a no-op same-size ftruncate()
    + fsync()).
  * Track [last_block, EXT_MAX_BLOCKS - 1] in ext4_truncate() (matching
    ext4_ext_truncate()'s exact last_block calculation) guarded by
    last_block < EXT_MAX_BLOCKS.

Changes since v1 (addressing Sashiko AI review):
- Patch 1: unchanged (no issues found).
- Patch 2:
  * Move ext4_fc_track_range() after `if (err) goto out_stop;` and
    guard it with `!ext4_handle_is_aborted(handle)`.
  * Call ext4_fc_track_range() for both extent-based and indirect-mapped
    inodes; indirect-mapped inodes have no hole entry inserted and
    continue to fall back safely to a full commit.

Testing on tytso/ext4.git dev (aceadbccd428f, -O fast_commit):
- Patch 1: xfstests generic/764 fails 100% before ("Structure needs
  cleaning" / "JBD2: journal recovery failed") and passes after;
  KUnit ext4_fast_commit_test 11/11 PASS.
- Patch 2: verified via /proc/fs/ext4/<dev>/fc_info that same-size
  ftruncate() (both dropping 64K FALLOC_FL_KEEP_SIZE post-EOF blocks
  and no-op same-size ftruncate(), warm and cold cache), truncate-to-0,
  and shrinking truncate all commit via fast commit (commits++,
  ineligible unchanged, es_miss == 0) and survive dm-flakey crash
  recovery with expected block counts and clean e2fsck -fn.

Xing Ma (2):
  ext4: fall back to full commit for unlinked or orphan inodes in fast
    commit
  ext4: track truncated block range in ext4_truncate() for fast commit

 fs/ext4/extents.c          |  5 +++++
 fs/ext4/fast_commit-test.c | 18 ++++++++++++++++++
 fs/ext4/fast_commit.c      | 17 +++++++++++++++++
 fs/ext4/inode.c            | 10 ++++++++++
 4 files changed, 50 insertions(+)


base-commit: aceadbccd428fb8e6593b27a3091d961f80225d1
-- 
2.39.5

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

end of thread, other threads:[~2026-11-30 23:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 23:05 [PATCH v3 0/2] ext4: fix fast commit orphan inode replay and truncate range tracking Xing Ma
2026-11-30 23:05 ` [PATCH v3 1/2] ext4: fall back to full commit for unlinked or orphan inodes in fast commit Xing Ma
2026-11-30 23:06 ` [PATCH v3 2/2] ext4: track truncated block range in ext4_truncate() for " Xing Ma
2026-11-30 23:28   ` sashiko-bot
2026-11-30 23:28 ` [PATCH v3 0/2] ext4: fix fast commit orphan inode replay and truncate range tracking sashiko-bot

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