This is a note to let you know that I've just added the patch titled ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE to the 5.16-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ext4-fix-fast-commit-may-miss-tracking-range-for-falloc_fl_zero_range.patch and it can be found in the queue-5.16 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 5e4d0eba1ccaf19f93222abdeda5a368be141785 Mon Sep 17 00:00:00 2001 From: Xin Yin <yinxin.x@xxxxxxxxxxxxx> Date: Tue, 21 Dec 2021 10:28:39 +0800 Subject: ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE From: Xin Yin <yinxin.x@xxxxxxxxxxxxx> commit 5e4d0eba1ccaf19f93222abdeda5a368be141785 upstream. when call falloc with FALLOC_FL_ZERO_RANGE, to set an range to unwritten, which has been already initialized. If the range is align to blocksize, fast commit will not track range for this change. Also track range for unwritten range in ext4_map_blocks(). Signed-off-by: Xin Yin <yinxin.x@xxxxxxxxxxxxx> Reviewed-by: Harshad Shirwadkar <harshadshirwadkar@xxxxxxxxx> Link: https://lore.kernel.org/r/20211221022839.374606-1-yinxin.x@xxxxxxxxxxxxx Signed-off-by: Theodore Ts'o <tytso@xxxxxxx> Cc: stable@xxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/ext4/extents.c | 2 -- fs/ext4/inode.c | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4647,8 +4647,6 @@ static long ext4_zero_range(struct file ret = ext4_mark_inode_dirty(handle, inode); if (unlikely(ret)) goto out_handle; - ext4_fc_track_range(handle, inode, offset >> inode->i_sb->s_blocksize_bits, - (offset + len - 1) >> inode->i_sb->s_blocksize_bits); /* Zero out partial block at the edges of the range */ ret = ext4_zero_partial_blocks(handle, inode, offset, len); if (ret >= 0) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -741,10 +741,11 @@ out_sem: if (ret) return ret; } - ext4_fc_track_range(handle, inode, map->m_lblk, - map->m_lblk + map->m_len - 1); } - + if (retval > 0 && (map->m_flags & EXT4_MAP_UNWRITTEN || + map->m_flags & EXT4_MAP_MAPPED)) + ext4_fc_track_range(handle, inode, map->m_lblk, + map->m_lblk + map->m_len - 1); if (retval < 0) ext_debug(inode, "failed with err %d\n", retval); return retval; Patches currently in stable-queue which might be from yinxin.x@xxxxxxxxxxxxx are queue-5.16/ext4-fix-fast-commit-may-miss-tracking-range-for-falloc_fl_zero_range.patch