Re: [PATCH v6 04/31] ext4: set EXT4_MAP_NEW flag for delayed allocated blocks

From: Ojaswin Mujoo

Date: Thu Sep 24 2026 - 07:49:14 EST


On Thu, Sep 03, 2026 at 08:35:16PM +0800, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@xxxxxxxxxx>
>
> Set EXT4_MAP_NEW in ext4_da_map_blocks() to properly indicate that a
> new delayed allocation block has been inserted, allowing callers to
> distinguish newly created delayed extents from existing ones.
>
> Currently, the buffer_head caller, ext4_da_get_block_prep(), does not
> consume this flag. It intercepts EXT4_MAP_DELAYED and returns early, and
> unconditionally calls set_buffer_new(bh) so EXT4_MAP_NEW is not used.
> The flag is prepared for the iomap buffered I/O path added later.
>
> Reported-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx>
> Link: https://lore.kernel.org/linux-ext4/cc05c17d-163e-4251-b2c9-aa3a6f9555d7@xxxxxxxxxxxxxxx/
> Signed-off-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 4fc0d331c49d..84991fe99071 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1990,7 +1990,7 @@ static int ext4_da_map_blocks(struct inode *inode, struct ext4_map_blocks *map)
> }
> }
>
> - map->m_flags |= EXT4_MAP_DELAYED;
> + map->m_flags |= EXT4_MAP_DELAYED | EXT4_MAP_NEW;

Looks good, feel free to add:

Reviewed-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx>

Regards,
ojaswin

> retval = ext4_insert_delayed_blocks(inode, map->m_lblk, map->m_len);
> if (!retval)
> map->m_seq = READ_ONCE(EXT4_I(inode)->i_es_seq);
> --
> 2.52.0
>