All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE
@ 2021-12-21  2:28 Xin Yin
  2021-12-23  2:41 ` harshad shirwadkar
  2021-12-24  0:27 ` Theodore Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Xin Yin @ 2021-12-21  2:28 UTC (permalink / raw)
  To: harshadshirwadkar, tytso, adilger.kernel
  Cc: linux-ext4, linux-kernel, Xin Yin

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@bytedance.com>
---
v2: change to track unwritten range in ext4_map_blocks()
---
 fs/ext4/extents.c | 2 --
 fs/ext4/inode.c   | 7 ++++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 9229ab1f99c5..6bce319f3bcd 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4599,8 +4599,6 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 	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)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0afab6d5c65b..47ad4b8cb503 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -741,10 +741,11 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
 			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;
-- 
2.20.1


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

* Re: [PATCH v2] ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE
  2021-12-21  2:28 [PATCH v2] ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE Xin Yin
@ 2021-12-23  2:41 ` harshad shirwadkar
  2021-12-24  0:27 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: harshad shirwadkar @ 2021-12-23  2:41 UTC (permalink / raw)
  To: Xin Yin
  Cc: Theodore Y. Ts'o, Andreas Dilger, Ext4 Developers List, linux-kernel

Looks good, thanks!

Reviewed-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

On Mon, Dec 20, 2021 at 6:28 PM Xin Yin <yinxin.x@bytedance.com> wrote:
>
> 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@bytedance.com>
> ---
> v2: change to track unwritten range in ext4_map_blocks()
> ---
>  fs/ext4/extents.c | 2 --
>  fs/ext4/inode.c   | 7 ++++---
>  2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 9229ab1f99c5..6bce319f3bcd 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4599,8 +4599,6 @@ static long ext4_zero_range(struct file *file, loff_t offset,
>         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)
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 0afab6d5c65b..47ad4b8cb503 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -741,10 +741,11 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
>                         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;
> --
> 2.20.1
>

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

* Re: [PATCH v2] ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE
  2021-12-21  2:28 [PATCH v2] ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE Xin Yin
  2021-12-23  2:41 ` harshad shirwadkar
@ 2021-12-24  0:27 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2021-12-24  0:27 UTC (permalink / raw)
  To: harshadshirwadkar, adilger.kernel, Xin Yin
  Cc: Theodore Ts'o, linux-kernel, linux-ext4

On Tue, 21 Dec 2021 10:28:39 +0800, Xin Yin wrote:
> 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().
> 
> 
> [...]

Applied, thanks!

[1/1] ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE
      commit: f6c90a2bcabcfc56d91aa5091b76ce8082de7d68

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

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

end of thread, other threads:[~2021-12-24  0:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21  2:28 [PATCH v2] ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE Xin Yin
2021-12-23  2:41 ` harshad shirwadkar
2021-12-24  0:27 ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.