Re: [PATCH v4 1/2] ext4: fix the fast commit range of a punched hole
From: Zhang Yi
Date: Fri Dec 04 2026 - 01:56:03 EST
On 12/3/2026 10:15 PM, Ding Feng wrote:
> 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.
>
> Fixes: aa75f4d3daae ("ext4: main fast-commit commit path")
> Signed-off-by: Ding Feng <dingf3ng@xxxxxxxxx>
Looks good to me.
Reviewed-by: Zhang Yi <yi.zhang@xxxxxxxxxx>
> ---
> fs/ext4/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 07a62d856..866c1d92d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -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))