Currently, callers like ext4_convert_unwritten_extents() pass
EXT4_EX_NOCACHE flag to avoid caching extents however this is not
respected by ext4_convert_unwritten_extents_endio(). Hence, modify it to
accept flags from the caller and to pass the flags on to other extent
manipulation functions it calls. This makes sure the NOCACHE flag is
respected throughout the code path.
Also, since the caller already passes METADATA_NOFAIL and CONVERT flags
we don't need to explicitly pass it anymore.
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
---
fs/ext4/extents.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 5228196f5ad4..460a70e6dae0 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3785,7 +3785,7 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
static struct ext4_ext_path *
ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
struct ext4_map_blocks *map,
- struct ext4_ext_path *path)
+ struct ext4_ext_path *path, int flags)
{
struct ext4_extent *ex;
ext4_lblk_t ee_block;
@@ -3802,9 +3802,6 @@ ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
(unsigned long long)ee_block, ee_len);
if (ee_block != map->m_lblk || ee_len > map->m_len) {
- int flags = EXT4_GET_BLOCKS_CONVERT |
- EXT4_GET_BLOCKS_METADATA_NOFAIL;
-
path = ext4_split_convert_extents(handle, inode, map, path,
flags, NULL);
if (IS_ERR(path))
@@ -3943,7 +3940,7 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
/* IO end_io complete, convert the filled extent to written */
if (flags & EXT4_GET_BLOCKS_CONVERT) {
path = ext4_convert_unwritten_extents_endio(handle, inode,
- map, path);
+ map, path, flags);
if (IS_ERR(path))
return path;
ext4_update_inode_fsync_trans(handle, inode, 1);
--
2.51.0
Hi, Ojaswin!
On 1/4/2026 8:19 PM, Ojaswin Mujoo wrote:
> Currently, callers like ext4_convert_unwritten_extents() pass
> EXT4_EX_NOCACHE flag to avoid caching extents however this is not
> respected by ext4_convert_unwritten_extents_endio(). Hence, modify it to
> accept flags from the caller and to pass the flags on to other extent
> manipulation functions it calls. This makes sure the NOCACHE flag is
> respected throughout the code path.
>
> Also, since the caller already passes METADATA_NOFAIL and CONVERT flags
> we don't need to explicitly pass it anymore.
Thank you for the refactor! One comment below.
>
> Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
> ---
> fs/ext4/extents.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 5228196f5ad4..460a70e6dae0 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3785,7 +3785,7 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
> static struct ext4_ext_path *
> ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
> struct ext4_map_blocks *map,
> - struct ext4_ext_path *path)
> + struct ext4_ext_path *path, int flags)
> {
> struct ext4_extent *ex;
> ext4_lblk_t ee_block;
> @@ -3802,9 +3802,6 @@ ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
> (unsigned long long)ee_block, ee_len);
>
> if (ee_block != map->m_lblk || ee_len > map->m_len) {
> - int flags = EXT4_GET_BLOCKS_CONVERT |
> - EXT4_GET_BLOCKS_METADATA_NOFAIL;
> -
> path = ext4_split_convert_extents(handle, inode, map, path,
> flags, NULL);
> if (IS_ERR(path))
There is another instance of ext4_find_extent() below that does not respect
the EXT4_EX_NOCACHE flag. I think we should pass the flag as well.
Thanks,
Yi.
> @@ -3943,7 +3940,7 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
> /* IO end_io complete, convert the filled extent to written */
> if (flags & EXT4_GET_BLOCKS_CONVERT) {
> path = ext4_convert_unwritten_extents_endio(handle, inode,
> - map, path);
> + map, path, flags);
> if (IS_ERR(path))
> return path;
> ext4_update_inode_fsync_trans(handle, inode, 1);
On Wed, Jan 07, 2026 at 02:33:36PM +0800, Zhang Yi wrote:
> Hi, Ojaswin!
>
> On 1/4/2026 8:19 PM, Ojaswin Mujoo wrote:
> > Currently, callers like ext4_convert_unwritten_extents() pass
> > EXT4_EX_NOCACHE flag to avoid caching extents however this is not
> > respected by ext4_convert_unwritten_extents_endio(). Hence, modify it to
> > accept flags from the caller and to pass the flags on to other extent
> > manipulation functions it calls. This makes sure the NOCACHE flag is
> > respected throughout the code path.
> >
> > Also, since the caller already passes METADATA_NOFAIL and CONVERT flags
> > we don't need to explicitly pass it anymore.
>
> Thank you for the refactor! One comment below.
>
> >
> > Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
> > ---
> > fs/ext4/extents.c | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> > index 5228196f5ad4..460a70e6dae0 100644
> > --- a/fs/ext4/extents.c
> > +++ b/fs/ext4/extents.c
> > @@ -3785,7 +3785,7 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
> > static struct ext4_ext_path *
> > ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
> > struct ext4_map_blocks *map,
> > - struct ext4_ext_path *path)
> > + struct ext4_ext_path *path, int flags)
> > {
> > struct ext4_extent *ex;
> > ext4_lblk_t ee_block;
> > @@ -3802,9 +3802,6 @@ ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
> > (unsigned long long)ee_block, ee_len);
> >
> > if (ee_block != map->m_lblk || ee_len > map->m_len) {
> > - int flags = EXT4_GET_BLOCKS_CONVERT |
> > - EXT4_GET_BLOCKS_METADATA_NOFAIL;
> > -
> > path = ext4_split_convert_extents(handle, inode, map, path,
> > flags, NULL);
> > if (IS_ERR(path))
>
> There is another instance of ext4_find_extent() below that does not respect
> the EXT4_EX_NOCACHE flag. I think we should pass the flag as well.
>
> Thanks,
> Yi.
Hey Yi, thanks for the review.
Yes you are right, its removed in later commits but for completeness
I'll add it there.
Thanks,
ojaswin
>
> > @@ -3943,7 +3940,7 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
> > /* IO end_io complete, convert the filled extent to written */
> > if (flags & EXT4_GET_BLOCKS_CONVERT) {
> > path = ext4_convert_unwritten_extents_endio(handle, inode,
> > - map, path);
> > + map, path, flags);
> > if (IS_ERR(path))
> > return path;
> > ext4_update_inode_fsync_trans(handle, inode, 1);
>
On Sun 04-01-26 17:49:17, Ojaswin Mujoo wrote:
> Currently, callers like ext4_convert_unwritten_extents() pass
> EXT4_EX_NOCACHE flag to avoid caching extents however this is not
> respected by ext4_convert_unwritten_extents_endio(). Hence, modify it to
> accept flags from the caller and to pass the flags on to other extent
> manipulation functions it calls. This makes sure the NOCACHE flag is
> respected throughout the code path.
>
> Also, since the caller already passes METADATA_NOFAIL and CONVERT flags
> we don't need to explicitly pass it anymore.
>
> Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/extents.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 5228196f5ad4..460a70e6dae0 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3785,7 +3785,7 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
> static struct ext4_ext_path *
> ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
> struct ext4_map_blocks *map,
> - struct ext4_ext_path *path)
> + struct ext4_ext_path *path, int flags)
> {
> struct ext4_extent *ex;
> ext4_lblk_t ee_block;
> @@ -3802,9 +3802,6 @@ ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
> (unsigned long long)ee_block, ee_len);
>
> if (ee_block != map->m_lblk || ee_len > map->m_len) {
> - int flags = EXT4_GET_BLOCKS_CONVERT |
> - EXT4_GET_BLOCKS_METADATA_NOFAIL;
> -
> path = ext4_split_convert_extents(handle, inode, map, path,
> flags, NULL);
> if (IS_ERR(path))
> @@ -3943,7 +3940,7 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
> /* IO end_io complete, convert the filled extent to written */
> if (flags & EXT4_GET_BLOCKS_CONVERT) {
> path = ext4_convert_unwritten_extents_endio(handle, inode,
> - map, path);
> + map, path, flags);
> if (IS_ERR(path))
> return path;
> ext4_update_inode_fsync_trans(handle, inode, 1);
> --
> 2.51.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
© 2016 - 2026 Red Hat, Inc.