]> git.ipfire.org Git - thirdparty/linux.git/commit
ext4: fast commit: avoid i_data_sem by dropping ext4_map_blocks() in snapshots
authorLi Chen <me@linux.beauty>
Fri, 15 May 2026 09:18:25 +0000 (17:18 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 3 Jun 2026 14:26:36 +0000 (10:26 -0400)
commit22d887e06a57261df58404c8dce50c4ef37549ed
tree8f0d998867f6e0ebc2d840aaae621a0873f5c1db
parent2b9b216628fd9352f9c791701c8990d05736aa90
ext4: fast commit: avoid i_data_sem by dropping ext4_map_blocks() in snapshots

Commit-time snapshots run under jbd2_journal_lock_updates(), so the work
done there must stay bounded.

The snapshot path still used ext4_map_blocks() to build data ranges. This
can take i_data_sem and pulls the mapping code into the snapshot logic.
Build inode data range snapshots from the extent status tree instead.

The extent status tree is a cache, not an authoritative source. If the
needed information is missing or unstable (e.g. delayed allocation), treat
the transaction as fast commit ineligible and fall back to full commit.

Also cap the number of inodes and ranges snapshotted per fast commit and
allocate range records from a dedicated slab cache. The inode pointer
array is allocated outside the updates-locked window.

Testing: QEMU/KVM guest, virtio-pmem + dax, ext4 -O fast_commit, mounted
dax,noatime. Ran python3 500x {4K write + fsync}, fallocate 256M, and
python3 500x {creat + fsync(dir)} without lockdep splats or errors.

Signed-off-by: Li Chen <chenl311@chinatelecom.cn>
Link: https://patch.msgid.link/20260515091829.194810-6-me@linux.beauty
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/fast_commit.c