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 v3 1/2] ext4: fix the fast commit range of a punched hole
Date: Thu, 3 Dec 2026 21:06:07 +0800 [thread overview]
Message-ID: <20261203130608.64892-2-dingf3ng@gmail.com> (raw)
In-Reply-To: <20261203130608.64892-1-dingf3ng@gmail.com>
ext4_fc_track_range() takes an inclusive end block: __track_range()
records end - start + 1 blocks. ext4_punch_hole() passes end_lblk, the
first block after the hole, so fast commit tracks one block more than
the punch removed, and it is called even when the hole covers no whole
block.
The extra block also wraps the length: with huge_file, s_maxbytes is
0xffffffff blocks, so a hole from block 0 to s_maxbytes records a
length of 0, which ext4_fc_snapshot_inode_data() reads as no change to
the file's blocks. Today the hole stops at the block that holds i_size,
so only a file that large gets there; the next patch lets the hole run
to s_maxbytes on any file.
Track [start_lblk, end_lblk - 1], and only when blocks were removed.
Keep queueing the inode for every punch, which the call at the end did
for a hole within one block, by tracking the inode before the removal.
Fixes: aa75f4d3daae ("ext4: main fast-commit commit path")
Signed-off-by: Ding Feng <dingf3ng@gmail.com>
---
fs/ext4/inode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 07a62d856..26cf00ff8 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5426,10 +5426,10 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
start_lblk = EXT4_B_TO_LBLK(inode, offset);
end_lblk = end >> inode->i_blkbits;
+ ext4_fc_track_inode(handle, inode);
if (end_lblk > start_lblk) {
ext4_lblk_t hole_len = end_lblk - start_lblk;
- ext4_fc_track_inode(handle, inode);
ext4_check_map_extents_env(inode);
down_write(&EXT4_I(inode)->i_data_sem);
ext4_discard_preallocations(inode);
@@ -5450,8 +5450,8 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
ext4_es_insert_extent(inode, start_lblk, hole_len, ~0,
EXTENT_STATUS_HOLE, 0);
up_write(&EXT4_I(inode)->i_data_sem);
+ ext4_fc_track_range(handle, inode, start_lblk, end_lblk - 1);
}
- ext4_fc_track_range(handle, inode, start_lblk, end_lblk);
ret = ext4_mark_inode_dirty(handle, inode);
if (unlikely(ret))
--
2.39.5
next prev parent reply other threads:[~2026-12-03 13:06 UTC|newest]
Thread overview: 3+ 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 ` Ding Feng [this message]
2026-12-03 13:06 ` [PATCH v3 2/2] " 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=20261203130608.64892-2-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